generated from liquibase/liquibase-extension-example
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Override the default implementation to ARRAY, MAP and STRUCT c…
…omplex types as Liquibase core does not know how to handle values between <> in the data type.
- Loading branch information
1 parent
0c6e3a5
commit 8798462
Showing
5 changed files
with
49 additions
and
76 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
src/main/java/liquibase/ext/databricks/datatype/ArrayIntegerDataTypeDatabricks.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/main/java/liquibase/ext/databricks/datatype/ArrayStringDataTypeDatabricks.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/liquibase/ext/databricks/snapshot/jvm/ColumnSnapshotGeneratorDatabricks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package liquibase.ext.databricks.snapshot.jvm; | ||
|
||
import liquibase.database.Database; | ||
import liquibase.exception.DatabaseException; | ||
import liquibase.ext.databricks.database.DatabricksDatabase; | ||
import liquibase.snapshot.CachedRow; | ||
import liquibase.snapshot.SnapshotGenerator; | ||
import liquibase.snapshot.jvm.ColumnSnapshotGenerator; | ||
import liquibase.structure.DatabaseObject; | ||
import liquibase.structure.core.Column; | ||
import liquibase.structure.core.DataType; | ||
|
||
public class ColumnSnapshotGeneratorDatabricks extends ColumnSnapshotGenerator { | ||
|
||
@Override | ||
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) { | ||
if (database instanceof DatabricksDatabase) { | ||
return super.getPriority(objectType, database) + PRIORITY_DATABASE; | ||
} else { | ||
return PRIORITY_NONE; | ||
} | ||
} | ||
|
||
@Override | ||
public Class<? extends SnapshotGenerator>[] replaces() { | ||
return new Class[] { ColumnSnapshotGenerator.class }; | ||
} | ||
|
||
/** | ||
* Override the default implementation to ARRAY, MAP and STRUCT complex types as | ||
* Liquibase core does not know how to handle values between <> in the data type. | ||
*/ | ||
@Override | ||
protected DataType readDataType(CachedRow columnMetadataResultSet, Column column, Database database) throws DatabaseException { | ||
String dataType = (String) columnMetadataResultSet.get("TYPE_NAME"); | ||
if (dataType != null && database instanceof DatabricksDatabase | ||
&& (dataType.toUpperCase().startsWith("ARRAY") | ||
|| dataType.toUpperCase().startsWith("MAP") | ||
|| dataType.toUpperCase().startsWith("STRUCT"))) { | ||
DataType type = new DataType(dataType); | ||
type.setDataTypeId(columnMetadataResultSet.getInt("DATA_TYPE")); | ||
return type; | ||
} | ||
return super.readDataType(columnMetadataResultSet, column, database); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters