From 1f1aa6735fc25744a371988f994fe6b730bccbc1 Mon Sep 17 00:00:00 2001 From: KushnirykOleh Date: Thu, 1 Aug 2024 15:12:04 +0300 Subject: [PATCH 1/4] fixed supports and priorities --- .../AddCheckConstraintChangeDatabricks.java | 31 ++++---- ...AddCheckConstraintStatementDatabricks.java | 2 - ...dForeignKeyConstraintChangeDatabricks.java | 11 ++- .../AddLookupTableChangeDatabricks.java | 16 +--- .../analyzeTable/AnalyzeTableChange.java | 4 +- .../CreateTableChangeDatabricks.java | 7 +- .../DropCheckConstraintChangeDatabricks.java | 7 +- .../optimizeTable/OptimizeTableChange.java | 9 ++- .../change/vacuumTable/VacuumTableChange.java | 9 ++- .../database/CheckConstraintDatabricks.java | 78 ------------------- .../database/DatabricksConnection.java | 2 +- .../database/DatabricksDatabase.java | 4 +- .../ArrayIntegerDataTypeDatabricks.java | 9 +-- .../ArrayStringDataTypeDatabricks.java | 10 +-- .../datatype/BigintDatatypeDatabricks.java | 11 +-- .../datatype/BinaryDataTypeDatabricks.java | 13 +--- .../datatype/BooleanDatatypeDatabricks.java | 8 +- .../datatype/DatetimeDatatypeDatabricks.java | 8 +- .../datatype/DoubleDatatypeDatabricks.java | 7 +- .../datatype/FloatDatatypeDatabricks.java | 7 +- .../datatype/IntegerDatatypeDatabricks.java | 5 +- .../datatype/SmallintDatatypeDatabricks.java | 8 +- .../datatype/StringDatatypeDatabricks.java | 12 +-- .../datatype/TimestampDatatypeDatabricks.java | 54 ++++--------- .../datatype/TinyintDatatypeDatabricks.java | 9 +-- .../executor/DatabricksExecutor.java | 4 +- .../jvm/IndexSnapshotGeneratorDatabricks.java | 4 +- .../AddAutoIncrementGeneratorDatabricks.java | 2 +- .../AddColumnGeneratorDatabricks.java | 2 +- .../AddDefaultValueGeneratorDatabricks.java | 2 +- ...reignKeyConstraintGeneratorDatabricks.java | 2 +- .../AddPrimaryKeyGeneratorDatabricks.java | 4 +- ...ddUniqueConstraintGeneratorDatabricks.java | 2 +- .../CreateIndexGeneratorDatabricks.java | 3 +- .../CreateTableGeneratorDatabricks.java | 2 +- .../GetViewDefinitionGeneratorDatabricks.java | 2 +- .../InsertOrUpdateGeneratorDatabricks.java | 2 +- .../RenameColumnGeneratorDatabricks.java | 2 +- .../RenameTableGeneratorDatabricks.java | 2 +- .../RenameViewGeneratorDatabricks.java | 2 +- .../SetColumnRemarksGeneratorDatabricks.java | 2 +- .../SetTableRemarksGeneratorDatabricks.java | 2 +- .../UpdateGeneratorDatabricks.java | 2 +- .../liquibase.datatype.LiquibaseDataType | 15 ++-- 44 files changed, 135 insertions(+), 264 deletions(-) delete mode 100644 src/main/java/liquibase/ext/databricks/database/CheckConstraintDatabricks.java diff --git a/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintChangeDatabricks.java b/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintChangeDatabricks.java index 8e5f0af4..ff0033f6 100644 --- a/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintChangeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintChangeDatabricks.java @@ -4,13 +4,14 @@ import liquibase.database.Database; import liquibase.ext.databricks.change.dropCheckConstraint.DropCheckConstraintChangeDatabricks; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.statement.SqlStatement; + import java.text.MessageFormat; -import liquibase.ext.databricks.database.DatabricksDatabase; @DatabaseChange(name = "addCheckConstraint", description = "Adds check constraint to Delta Table", - priority = DatabricksDatabase.PRIORITY_DEFAULT + 200, + priority = PrioritizedService.PRIORITY_DATABASE, appliesTo = {"column"} ) public class AddCheckConstraintChangeDatabricks extends AbstractChange { @@ -23,11 +24,17 @@ public class AddCheckConstraintChangeDatabricks extends AbstractChange { private String constraintBody; + + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } + public String getCatalogName() { return catalogName; } - public void setCatalogName (String catalogName) { + public void setCatalogName(String catalogName) { this.catalogName = catalogName; } @@ -35,7 +42,7 @@ public String getTableName() { return tableName; } - public void setTableName (String tableName) { + public void setTableName(String tableName) { this.tableName = tableName; } @@ -43,15 +50,12 @@ public String getSchemaName() { return schemaName; } - public void setSchemaName (String schemaName) { + public void setSchemaName(String schemaName) { this.schemaName = schemaName; } - // Name of Delta Table Constraint - @DatabaseChangeProperty( - description = "Name of the check constraint" - ) + @DatabaseChangeProperty(description = "Name of the check constraint") public String getConstraintName() { return this.constraintName; } @@ -60,9 +64,7 @@ public void setConstraintName(String name) { this.constraintName = name; } - - // The is the SQL expression involving the contraint - + // This is the SQL expression involving the constraint @DatabaseChangeProperty( serializationType = SerializationType.DIRECT_VALUE ) @@ -76,7 +78,8 @@ public void setConstraintBody(String body) { @Override public String getConfirmationMessage() { - return MessageFormat.format("{0}.{1}.{2} successfully Added check constraint {3}.", getCatalogName(), getSchemaName(), getTableName(), getConstraintName()); + return MessageFormat.format("{0}.{1}.{2} successfully Added check constraint {3}.", getCatalogName(), getSchemaName(), getTableName(), + getConstraintName()); } protected Change[] createInverses() { @@ -100,6 +103,6 @@ public SqlStatement[] generateStatements(Database database) { statement.setConstraintName(getConstraintName()); statement.setConstraintBody(getConstraintBody()); - return new SqlStatement[] {statement}; + return new SqlStatement[]{statement}; } } diff --git a/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintStatementDatabricks.java b/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintStatementDatabricks.java index f635feca..8d39489d 100644 --- a/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintStatementDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/addCheckConstraint/AddCheckConstraintStatementDatabricks.java @@ -8,8 +8,6 @@ public class AddCheckConstraintStatementDatabricks extends AbstractSqlStatement private String tableName; private String constraintName; private String constraintBody; - private boolean validate = true; - private boolean disabled; public String getCatalogName() { diff --git a/src/main/java/liquibase/ext/databricks/change/addForeignKeyConstraint/AddForeignKeyConstraintChangeDatabricks.java b/src/main/java/liquibase/ext/databricks/change/addForeignKeyConstraint/AddForeignKeyConstraintChangeDatabricks.java index c4412667..ae55635d 100644 --- a/src/main/java/liquibase/ext/databricks/change/addForeignKeyConstraint/AddForeignKeyConstraintChangeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/addForeignKeyConstraint/AddForeignKeyConstraintChangeDatabricks.java @@ -1,11 +1,11 @@ package liquibase.ext.databricks.change.addForeignKeyConstraint; -import liquibase.ext.databricks.database.DatabricksDatabase; - import liquibase.change.*; import liquibase.database.Database; import liquibase.database.DatabaseFactory; import liquibase.exception.UnexpectedLiquibaseException; +import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.snapshot.SnapshotGeneratorFactory; import liquibase.statement.SqlStatement; import liquibase.statement.core.AddForeignKeyConstraintStatement; @@ -23,8 +23,9 @@ */ @DatabaseChange(name = "addForeignKeyConstraint", description = "Adds a foreign key constraint to an existing column", - priority = DatabricksDatabase.PRIORITY_DATABASE, + priority = PrioritizedService.PRIORITY_DATABASE, appliesTo = "column") +//TODO this class need refactoring as it copies parent class instead of properly inheriting it. public class AddForeignKeyConstraintChangeDatabricks extends AddForeignKeyConstraintChange { private String baseTableCatalogName; @@ -46,6 +47,10 @@ public class AddForeignKeyConstraintChangeDatabricks extends AddForeignKeyConstr private String onUpdate; private String onDelete; + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } @Override protected String[] createSupportedDatabasesMetaData( diff --git a/src/main/java/liquibase/ext/databricks/change/addLookupTable/AddLookupTableChangeDatabricks.java b/src/main/java/liquibase/ext/databricks/change/addLookupTable/AddLookupTableChangeDatabricks.java index d65f7ca8..b9ba8f03 100644 --- a/src/main/java/liquibase/ext/databricks/change/addLookupTable/AddLookupTableChangeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/addLookupTable/AddLookupTableChangeDatabricks.java @@ -6,37 +6,27 @@ import liquibase.change.core.*; import liquibase.ext.databricks.database.DatabricksDatabase; -import liquibase.ext.databricks.change.createTable.CreateTableStatementDatabricks; -import liquibase.ext.databricks.change.createTable.CreateTableChangeDatabricks; import liquibase.Scope; import liquibase.change.*; import liquibase.database.Database; -import liquibase.database.core.DB2Database; import liquibase.database.core.Db2zDatabase; -import liquibase.database.core.HsqlDatabase; -import liquibase.database.core.InformixDatabase; -import liquibase.database.core.MSSQLDatabase; import liquibase.database.core.OracleDatabase; -import liquibase.database.core.SybaseASADatabase; -import liquibase.datatype.DataTypeFactory; import liquibase.exception.ValidationErrors; +import liquibase.servicelocator.PrioritizedService; import liquibase.snapshot.SnapshotGeneratorFactory; -import liquibase.statement.NotNullConstraint; import liquibase.statement.SqlStatement; -import liquibase.statement.core.CreateTableStatement; import liquibase.statement.core.RawSqlStatement; -import liquibase.statement.core.ReorganizeTableStatement; import liquibase.structure.core.Column; import liquibase.structure.core.ForeignKey; import liquibase.structure.core.Table; import liquibase.change.core.AddLookupTableChange; -import static liquibase.statement.SqlStatement.EMPTY_SQL_STATEMENT; /** * Extracts data from an existing column to create a lookup table. * A foreign key is created between the old column and the new lookup table. */ -@DatabaseChange(name = "addLookupTable", priority = DatabricksDatabase.PRIORITY_DATABASE + 500, appliesTo = "column", +//TODO this class need refactoring as it copies parent class instead of properly inheriting it. +@DatabaseChange(name = "addLookupTable", priority = PrioritizedService.PRIORITY_DATABASE, appliesTo = "column", description = "Creates a lookup table containing values stored in a column and creates a foreign key to the new table.") public class AddLookupTableChangeDatabricks extends AddLookupTableChange { diff --git a/src/main/java/liquibase/ext/databricks/change/analyzeTable/AnalyzeTableChange.java b/src/main/java/liquibase/ext/databricks/change/analyzeTable/AnalyzeTableChange.java index 95ff2753..f72b3082 100644 --- a/src/main/java/liquibase/ext/databricks/change/analyzeTable/AnalyzeTableChange.java +++ b/src/main/java/liquibase/ext/databricks/change/analyzeTable/AnalyzeTableChange.java @@ -3,17 +3,17 @@ import liquibase.change.AbstractChange; import liquibase.change.Change; -import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.statement.SqlStatement; import java.util.Collections; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Map; -@DatabaseChange(name = "analyzeTable", description = "Analyze Table Stats", priority = ChangeMetaData.PRIORITY_DEFAULT) +@DatabaseChange(name = "analyzeTable", description = "Analyze Table Stats", priority = PrioritizedService.PRIORITY_DATABASE) public class AnalyzeTableChange extends AbstractChange { private String catalogName; diff --git a/src/main/java/liquibase/ext/databricks/change/createTable/CreateTableChangeDatabricks.java b/src/main/java/liquibase/ext/databricks/change/createTable/CreateTableChangeDatabricks.java index a5ec4de7..a6d087af 100644 --- a/src/main/java/liquibase/ext/databricks/change/createTable/CreateTableChangeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/createTable/CreateTableChangeDatabricks.java @@ -5,11 +5,12 @@ import liquibase.change.core.CreateTableChange; import liquibase.database.Database; import liquibase.exception.ValidationErrors; +import liquibase.ext.databricks.database.DatabricksDatabase; import liquibase.servicelocator.PrioritizedService; import liquibase.statement.core.CreateTableStatement; -@DatabaseChange(name = "createTable", description = "Create Table", priority = PrioritizedService.PRIORITY_DATABASE +500) +@DatabaseChange(name = "createTable", description = "Create Table", priority = PrioritizedService.PRIORITY_DATABASE) public class CreateTableChangeDatabricks extends CreateTableChange { private String tableFormat; @@ -18,6 +19,10 @@ public class CreateTableChangeDatabricks extends CreateTableChange { private String partitionColumns; private ExtendedTableProperties extendedTableProperties; + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } @Override public ValidationErrors validate(Database database) { diff --git a/src/main/java/liquibase/ext/databricks/change/dropCheckConstraint/DropCheckConstraintChangeDatabricks.java b/src/main/java/liquibase/ext/databricks/change/dropCheckConstraint/DropCheckConstraintChangeDatabricks.java index 56e498e2..88248af6 100644 --- a/src/main/java/liquibase/ext/databricks/change/dropCheckConstraint/DropCheckConstraintChangeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/change/dropCheckConstraint/DropCheckConstraintChangeDatabricks.java @@ -6,11 +6,12 @@ import liquibase.change.DatabaseChangeProperty; import liquibase.database.Database; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.statement.SqlStatement; import java.text.MessageFormat; -@DatabaseChange(name = "dropCheckConstraint", description = "Drops check constraint to Delta Table", priority = DatabricksDatabase.PRIORITY_DEFAULT + 200) +@DatabaseChange(name = "dropCheckConstraint", description = "Drops check constraint to Delta Table", priority = PrioritizedService.PRIORITY_DATABASE) public class DropCheckConstraintChangeDatabricks extends AbstractChange { private String catalogName; @@ -43,6 +44,10 @@ public void setSchemaName (String schemaName) { this.schemaName = schemaName; } + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } // Name of Delta Table Constraint @DatabaseChangeProperty( diff --git a/src/main/java/liquibase/ext/databricks/change/optimizeTable/OptimizeTableChange.java b/src/main/java/liquibase/ext/databricks/change/optimizeTable/OptimizeTableChange.java index 8ce3128d..54d9681f 100644 --- a/src/main/java/liquibase/ext/databricks/change/optimizeTable/OptimizeTableChange.java +++ b/src/main/java/liquibase/ext/databricks/change/optimizeTable/OptimizeTableChange.java @@ -5,13 +5,15 @@ import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; +import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.statement.SqlStatement; import liquibase.change.Change; import java.text.MessageFormat; import java.util.ArrayList; -@DatabaseChange(name = "optimizeTable", description = "Optimize and ZOrder Table", priority = ChangeMetaData.PRIORITY_DEFAULT) +@DatabaseChange(name = "optimizeTable", description = "Optimize and ZOrder Table", priority = PrioritizedService.PRIORITY_DATABASE) public class OptimizeTableChange extends AbstractChange { private String catalogName; @@ -56,6 +58,11 @@ public String getConfirmationMessage() { return MessageFormat.format("{0}.{1}.{2} successfully optimized.", getCatalogName(), getSchemaName(), getTableName()); } + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } + @Override protected Change[] createInverses() { // No Op for Databricks optimize statement. there is no rolling this back. diff --git a/src/main/java/liquibase/ext/databricks/change/vacuumTable/VacuumTableChange.java b/src/main/java/liquibase/ext/databricks/change/vacuumTable/VacuumTableChange.java index 976e705a..65177f3a 100644 --- a/src/main/java/liquibase/ext/databricks/change/vacuumTable/VacuumTableChange.java +++ b/src/main/java/liquibase/ext/databricks/change/vacuumTable/VacuumTableChange.java @@ -6,11 +6,13 @@ import liquibase.change.ChangeMetaData; import liquibase.change.DatabaseChange; import liquibase.database.Database; +import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.statement.SqlStatement; import java.text.MessageFormat; -@DatabaseChange(name = "vacuumTable", description = "Vacuum Old Files from Table", priority = ChangeMetaData.PRIORITY_DEFAULT + 200) +@DatabaseChange(name = "vacuumTable", description = "Vacuum Old Files from Table", priority = PrioritizedService.PRIORITY_DATABASE) public class VacuumTableChange extends AbstractChange { private String catalogName; @@ -55,6 +57,11 @@ public String getConfirmationMessage() { return MessageFormat.format("{0}.{1}.{2} successfully vacuumed.", getCatalogName(), getSchemaName(), getTableName()); } + @Override + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; + } + @Override protected Change[] createInverses() { // No Op for Databricks optimize statement. there is no rolling this back. diff --git a/src/main/java/liquibase/ext/databricks/database/CheckConstraintDatabricks.java b/src/main/java/liquibase/ext/databricks/database/CheckConstraintDatabricks.java deleted file mode 100644 index 00a01733..00000000 --- a/src/main/java/liquibase/ext/databricks/database/CheckConstraintDatabricks.java +++ /dev/null @@ -1,78 +0,0 @@ -package liquibase.ext.databricks.database; - -import liquibase.license.LicenseServiceUtils; -import liquibase.structure.AbstractDatabaseObject; -import liquibase.structure.DatabaseObject; -import liquibase.structure.core.Schema; -import liquibase.structure.core.Table; -import liquibase.util.StringUtil; - - -public class CheckConstraintDatabricks extends AbstractDatabaseObject { - public CheckConstraintDatabricks() { - } - - public DatabaseObject[] getContainingObjects() { - return null; - } - - public boolean snapshotByDefault() { - return LicenseServiceUtils.isProLicenseValid(); - } - - public String getName() { - return (String)this.getAttribute("name", String.class); - } - - public CheckConstraintDatabricks setName(String var1) { - this.setAttribute("name", var1); - return this; - } - - public Schema getSchema() { - return this.getTable() == null ? null : this.getTable().getSchema(); - } - - public Table getTable() { - return (Table)this.getAttribute("table", Table.class); - } - - public CheckConstraintDatabricks setTable(Table var1) { - this.setAttribute("table", var1); - return this; - } - - public String getBody() { - return (String)this.getAttribute("body", String.class); - } - - public CheckConstraintDatabricks setBody(String var1) { - this.setAttribute("body", var1); - return this; - } - - public String toString() { - Table var1; - return (var1 = this.getTable()) == null ? this.getName() : this.getName() + " on " + var1.getName(); - } - - public int compareTo(Object var1) { - return this.equals(var1) ? 0 : super.compareTo(var1); - } - - public boolean equals(Object var1) { - if (this == var1) { - return true; - } else if (var1 != null && this.getClass() == var1.getClass()) { - CheckConstraintDatabricks var2 = (CheckConstraintDatabricks)var1; - return this.getSchema() != null && var2.getSchema() != null ? this.getSchema().toString().equalsIgnoreCase(var2.getSchema().toString()) : this.getName().equalsIgnoreCase(var2.getName()); - } else { - return false; - } - } - - public int hashCode() { - return StringUtil.trimToEmpty(this.getName()).toLowerCase().hashCode(); - } -} - diff --git a/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java b/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java index df6cba36..4a2c84ef 100644 --- a/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java +++ b/src/main/java/liquibase/ext/databricks/database/DatabricksConnection.java @@ -86,7 +86,7 @@ public boolean supports(String url) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java b/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java index bd1a09ef..ea58755d 100644 --- a/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java +++ b/src/main/java/liquibase/ext/databricks/database/DatabricksDatabase.java @@ -18,8 +18,6 @@ public class DatabricksDatabase extends AbstractJdbcDatabase { - - public static final int DATABRICKS_PRIORITY_DATABASE = 1515; // define env variables for database public static final String PRODUCT_NAME = "databricks"; // Set default catalog - must be unity Catalog Enabled @@ -92,7 +90,7 @@ public Integer getDefaultPort() { @Override public int getPriority() { - return DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/datatype/ArrayIntegerDataTypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/ArrayIntegerDataTypeDatabricks.java index 90791681..f2bfe059 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/ArrayIntegerDataTypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/ArrayIntegerDataTypeDatabricks.java @@ -6,8 +6,9 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; -@DataTypeInfo(name = "array", minParameters = 0, maxParameters = 0, priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE) +@DataTypeInfo(name = "array", minParameters = 0, maxParameters = 0, priority = PrioritizedService.PRIORITY_DATABASE) public class ArrayIntegerDataTypeDatabricks extends LiquibaseDataType { @@ -29,12 +30,6 @@ public boolean supports(Database database) { return database instanceof DatabricksDatabase; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - @Override public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.STRING; diff --git a/src/main/java/liquibase/ext/databricks/datatype/ArrayStringDataTypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/ArrayStringDataTypeDatabricks.java index 2ce72df8..1a153e60 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/ArrayStringDataTypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/ArrayStringDataTypeDatabricks.java @@ -5,10 +5,10 @@ import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; -import liquibase.datatype.core.BigIntType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; -@DataTypeInfo(name = "array", minParameters = 0, maxParameters = 0, priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE) +@DataTypeInfo(name = "array", minParameters = 0, maxParameters = 0, priority = PrioritizedService.PRIORITY_DATABASE) public class ArrayStringDataTypeDatabricks extends LiquibaseDataType { @@ -29,12 +29,6 @@ public boolean supports(Database database) { return database instanceof DatabricksDatabase; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - @Override public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.STRING; diff --git a/src/main/java/liquibase/ext/databricks/datatype/BigintDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/BigintDatatypeDatabricks.java index 2e69dc32..57dd17a0 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/BigintDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/BigintDatatypeDatabricks.java @@ -7,10 +7,11 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; - -@DataTypeInfo(name = "bigint", aliases = {"java.sql.Types.BIGINT", "java.math.BigInteger", "java.lang.Long", "integer8", "bigserial", "serial8", "int8"}, minParameters = 0, maxParameters = 0, priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE) +@DataTypeInfo(name = "bigint", aliases = {"java.sql.Types.BIGINT", "java.math.BigInteger", "java.lang.Long", "integer8", "bigserial", "serial8", "int8"}, + minParameters = 0, maxParameters = 0, priority = PrioritizedService.PRIORITY_DATABASE) public class BigintDatatypeDatabricks extends BigIntType { private boolean autoIncrement; @@ -38,12 +39,6 @@ public boolean supports(Database database) { return database instanceof DatabricksDatabase; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - @Override public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; diff --git a/src/main/java/liquibase/ext/databricks/datatype/BinaryDataTypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/BinaryDataTypeDatabricks.java index 589316ff..25080e88 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/BinaryDataTypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/BinaryDataTypeDatabricks.java @@ -1,14 +1,15 @@ package liquibase.ext.databricks.datatype; -import liquibase.change.core.LoadDataChange; import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; -import liquibase.datatype.LiquibaseDataType; import liquibase.datatype.core.BlobType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; - +@DataTypeInfo(name = "binary", aliases = {"longblob", "java.sql.Types.BLOB", + "java.sql.Types.BINARY", "tinyblob", "mediumblob"}, minParameters = 0, maxParameters = 0 + , priority = PrioritizedService.PRIORITY_DATABASE) public class BinaryDataTypeDatabricks extends BlobType { @@ -22,12 +23,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { return super.toDatabaseDataType(database); } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - @Override public boolean supports(Database database) { return database instanceof DatabricksDatabase; diff --git a/src/main/java/liquibase/ext/databricks/datatype/BooleanDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/BooleanDatatypeDatabricks.java index e912ac6c..768fe5ce 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/BooleanDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/BooleanDatatypeDatabricks.java @@ -12,7 +12,8 @@ name = "boolean", minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, + priority = PrioritizedService.PRIORITY_DATABASE ) public class BooleanDatatypeDatabricks extends LiquibaseDataType { @@ -39,11 +40,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { } @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.BOOLEAN; } diff --git a/src/main/java/liquibase/ext/databricks/datatype/DatetimeDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/DatetimeDatatypeDatabricks.java index d59b14aa..478f9cfe 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/DatetimeDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/DatetimeDatatypeDatabricks.java @@ -6,13 +6,14 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; @DataTypeInfo( name = "timestamp", aliases = {"java.sql.Types.DATETIME", "datetime"}, minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + priority = PrioritizedService.PRIORITY_DATABASE ) public class DatetimeDatatypeDatabricks extends LiquibaseDataType { @@ -32,11 +33,6 @@ public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.DATE; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - @Override public boolean supports(Database database) { return database instanceof DatabricksDatabase; diff --git a/src/main/java/liquibase/ext/databricks/datatype/DoubleDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/DoubleDatatypeDatabricks.java index 202071d6..8b944812 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/DoubleDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/DoubleDatatypeDatabricks.java @@ -12,7 +12,8 @@ name = "double", minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + aliases = {"java.sql.Types.DOUBLE", "java.lang.Double"}, + priority = PrioritizedService.PRIORITY_DATABASE ) public class DoubleDatatypeDatabricks extends LiquibaseDataType { @@ -39,10 +40,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { } @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; } diff --git a/src/main/java/liquibase/ext/databricks/datatype/FloatDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/FloatDatatypeDatabricks.java index e3c232ba..41c188bb 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/FloatDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/FloatDatatypeDatabricks.java @@ -13,7 +13,8 @@ name = "float", minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + aliases = {"java.sql.Types.FLOAT", "java.lang.Float"}, + priority = PrioritizedService.PRIORITY_DATABASE ) public class FloatDatatypeDatabricks extends LiquibaseDataType { public FloatDatatypeDatabricks() { @@ -39,10 +40,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { } @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; } diff --git a/src/main/java/liquibase/ext/databricks/datatype/IntegerDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/IntegerDatatypeDatabricks.java index 113b0b08..bdf234f6 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/IntegerDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/IntegerDatatypeDatabricks.java @@ -6,13 +6,15 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; @DataTypeInfo( name = "int", minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + aliases = {"integer", "java.sql.Types.INTEGER", "java.lang.Integer"}, + priority = PrioritizedService.PRIORITY_DATABASE ) public class IntegerDatatypeDatabricks extends LiquibaseDataType { public IntegerDatatypeDatabricks() { @@ -37,6 +39,7 @@ public DatabaseDataType toDatabaseDataType(Database database) { } + @Override public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; } diff --git a/src/main/java/liquibase/ext/databricks/datatype/SmallintDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/SmallintDatatypeDatabricks.java index 6a833c6d..4c5a98f3 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/SmallintDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/SmallintDatatypeDatabricks.java @@ -6,13 +6,14 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; @DataTypeInfo( name = "smallint", aliases = {"java.sql.Types.SMALLINT", "short"}, minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + priority = PrioritizedService.PRIORITY_DATABASE ) public class SmallintDatatypeDatabricks extends LiquibaseDataType { @@ -32,11 +33,6 @@ public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - @Override public boolean supports(Database database) { return database instanceof DatabricksDatabase; diff --git a/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java index 4cddd1a2..41fc300d 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java @@ -4,17 +4,18 @@ import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; -import liquibase.datatype.core.VarcharType; +import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; @DataTypeInfo( name = "string", minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE, + priority = PrioritizedService.PRIORITY_DATABASE, aliases = { "varchar", "clob", "java.lang.String" } ) -public class StringDatatypeDatabricks extends VarcharType { +public class StringDatatypeDatabricks extends LiquibaseDataType { public StringDatatypeDatabricks() { } @@ -38,11 +39,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { } @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.STRING; } diff --git a/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java index 93b4114b..5c8d8b06 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java @@ -3,26 +3,34 @@ import liquibase.datatype.core.TimestampType; import liquibase.Scope; import liquibase.change.core.LoadDataChange; + import java.util.Locale; + import liquibase.GlobalConfiguration; import liquibase.database.Database; import liquibase.database.core.*; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; import liquibase.exception.DatabaseIncapableOfOperation; +import liquibase.servicelocator.PrioritizedService; import liquibase.util.StringUtil; import liquibase.util.grammar.ParseException; import liquibase.ext.databricks.database.DatabricksDatabase; + /** * Data type support for TIMESTAMP data types in various DBMS. All DBMS are at least expected to support the * year, month, day, hour, minute and second parts. Optionally, fractional seconds and time zone information can be * specified as well. */ -@DataTypeInfo(name = "timestamp", aliases = {"java.sql.Types.TIMESTAMP", "java.sql.Types.TIMESTAMP_WITH_TIMEZONE", "java.sql.Timestamp", "timestamptz"}, minParameters = 0, maxParameters = 0, priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE) + +//TODO refactor to simplify this class +@DataTypeInfo(name = "timestamp", aliases = {"java.sql.Types.TIMESTAMP", "java.sql.Types.TIMESTAMP_WITH_TIMEZONE", "java.sql.Timestamp", "timestamptz"}, + minParameters = 0, maxParameters = 0, priority = PrioritizedService.PRIORITY_DATABASE) public class TimestampDatatypeDatabricks extends TimestampType { /** * Returns a DBMS-specific String representation of this TimestampType for use in SQL statements. + * * @param database the database for which the String must be generated * @return a String with the DBMS-specific type specification */ @@ -58,41 +66,6 @@ public DatabaseDataType toDatabaseDataType(Database database) { } } - if (database instanceof MySQLDatabase) { - if (originalDefinition.contains(" ") || originalDefinition.contains("(")) { - return new DatabaseDataType(getRawDefinition()); - } - return super.toDatabaseDataType(database); - } - if (database instanceof MSSQLDatabase) { - if (Boolean.TRUE.equals(!GlobalConfiguration.CONVERT_DATA_TYPES.getCurrentValue()) - && originalDefinition.toLowerCase(Locale.US).startsWith("timestamp")) { - return new DatabaseDataType(database.escapeDataTypeName("timestamp")); - } - Object[] parameters = getParameters(); - if (parameters.length >= 1) { - final int paramValue = Integer.parseInt(parameters[0].toString()); - // If the scale for datetime2 is the database default anyway, omit it. - // If the scale is 8, omit it since it's not a valid value for datetime2 - if (paramValue > 7 || paramValue == (database.getDefaultScaleForNativeDataType("datetime2"))) { - parameters = new Object[0]; - - } - - } - return new DatabaseDataType(database.escapeDataTypeName("datetime2"), parameters); - } - if (database instanceof SybaseDatabase) { - return new DatabaseDataType(database.escapeDataTypeName("datetime")); - } - if (database instanceof AbstractDb2Database) { - Object[] parameters = getParameters(); - if ((parameters != null) && (parameters.length > 1)) { - parameters = new Object[] {parameters[1]}; - } - return new DatabaseDataType(database.escapeDataTypeName("timestamp"), parameters); - } - /* * From here on, we assume that we have a SQL standard compliant database that supports the * TIMESTAMP[(p)] [WITH TIME ZONE|WITHOUT TIME ZONE] syntax. p is the number of fractional digits, @@ -121,7 +94,7 @@ public DatabaseDataType toDatabaseDataType(Database database) { fractionalDigits = maxFractionalDigits; } // Do not return parameter p for Databricks - type = new DatabaseDataType("TIMESTAMP"); + type = new DatabaseDataType("TIMESTAMP"); } else { type = new DatabaseDataType("TIMESTAMP"); } @@ -149,7 +122,7 @@ public DatabaseDataType toDatabaseDataType(Database database) { || database instanceof OracleDatabase) || database instanceof H2Database || database instanceof HsqlDatabase - || database instanceof SybaseASADatabase){ + || database instanceof SybaseASADatabase) { String additionalInformation = this.getAdditionalInformation(); if (additionalInformation != null) { @@ -183,11 +156,10 @@ public DatabaseDataType toDatabaseDataType(Database database) { } @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + public boolean supports(Database database) { + return database instanceof DatabricksDatabase; } - @Override public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.DATE; diff --git a/src/main/java/liquibase/ext/databricks/datatype/TinyintDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/TinyintDatatypeDatabricks.java index 13ed54c3..96e9b551 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/TinyintDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/TinyintDatatypeDatabricks.java @@ -6,13 +6,14 @@ import liquibase.datatype.DatabaseDataType; import liquibase.datatype.LiquibaseDataType; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; @DataTypeInfo( name = "tinyint", aliases = {"java.sql.Types.TINYINT", "byte"}, minParameters = 0, maxParameters = 0, - priority = DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE + priority = PrioritizedService.PRIORITY_DATABASE ) public class TinyintDatatypeDatabricks extends LiquibaseDataType { @@ -32,12 +33,6 @@ public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { return LoadDataChange.LOAD_DATA_TYPE.NUMERIC; } - @Override - public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; - } - - @Override public boolean supports(Database database) { return database instanceof DatabricksDatabase; diff --git a/src/main/java/liquibase/ext/databricks/executor/DatabricksExecutor.java b/src/main/java/liquibase/ext/databricks/executor/DatabricksExecutor.java index dd06729f..a185e27a 100644 --- a/src/main/java/liquibase/ext/databricks/executor/DatabricksExecutor.java +++ b/src/main/java/liquibase/ext/databricks/executor/DatabricksExecutor.java @@ -5,16 +5,16 @@ import liquibase.exception.DatabaseException; import liquibase.executor.jvm.JdbcExecutor; import liquibase.ext.databricks.database.DatabricksDatabase; +import liquibase.servicelocator.PrioritizedService; import liquibase.sql.visitor.SqlVisitor; import liquibase.statement.SqlStatement; import java.util.List; -import static liquibase.ext.databricks.database.DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; public class DatabricksExecutor extends JdbcExecutor { @Override public int getPriority() { - return DATABRICKS_PRIORITY_DATABASE; + return PrioritizedService.PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/IndexSnapshotGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/IndexSnapshotGeneratorDatabricks.java index 87a65834..1ff5619f 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/IndexSnapshotGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/IndexSnapshotGeneratorDatabricks.java @@ -20,8 +20,8 @@ public class IndexSnapshotGeneratorDatabricks extends IndexSnapshotGenerator { @Override public int getPriority(Class objectType, Database database) { - if (super.getPriority(objectType, database) > 0 && database instanceof DatabricksDatabase) { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + if (database instanceof DatabricksDatabase) { + return super.getPriority(objectType, database) + PRIORITY_DATABASE; } else { return PRIORITY_NONE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddAutoIncrementGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddAutoIncrementGeneratorDatabricks.java index 918740fa..ddef3c61 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddAutoIncrementGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddAutoIncrementGeneratorDatabricks.java @@ -11,7 +11,7 @@ public class AddAutoIncrementGeneratorDatabricks extends AddAutoIncrementGenerat @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java index 1001a543..d9825d7a 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java @@ -19,7 +19,7 @@ public class AddColumnGeneratorDatabricks extends AddColumnGenerator { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddDefaultValueGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddDefaultValueGeneratorDatabricks.java index 320475a1..c1b3dfd7 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddDefaultValueGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddDefaultValueGeneratorDatabricks.java @@ -17,7 +17,7 @@ public class AddDefaultValueGeneratorDatabricks extends AddDefaultValueGenerator { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddForeignKeyConstraintGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddForeignKeyConstraintGeneratorDatabricks.java index c146ba94..1402f68c 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddForeignKeyConstraintGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddForeignKeyConstraintGeneratorDatabricks.java @@ -23,7 +23,7 @@ public boolean supports(AddForeignKeyConstraintStatement statement, Database dat @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddPrimaryKeyGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddPrimaryKeyGeneratorDatabricks.java index 236646dc..d92123a6 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddPrimaryKeyGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddPrimaryKeyGeneratorDatabricks.java @@ -16,12 +16,12 @@ public class AddPrimaryKeyGeneratorDatabricks extends AddPrimaryKeyGenerator { @Override public boolean supports(AddPrimaryKeyStatement statement, Database database) { - return (database instanceof DatabricksDatabase); + return database instanceof DatabricksDatabase; } @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddUniqueConstraintGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddUniqueConstraintGeneratorDatabricks.java index 47a9692a..3ddd7eb4 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddUniqueConstraintGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddUniqueConstraintGeneratorDatabricks.java @@ -12,7 +12,7 @@ public class AddUniqueConstraintGeneratorDatabricks extends AddUniqueConstraintG @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateIndexGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateIndexGeneratorDatabricks.java index c7784d8e..ae3b450a 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateIndexGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateIndexGeneratorDatabricks.java @@ -23,6 +23,7 @@ */ +//TODO not used - figure out -fix or delete public class CreateIndexGeneratorDatabricks extends CreateIndexGenerator { @Override @@ -32,7 +33,7 @@ public boolean supports(CreateIndexStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateTableGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateTableGeneratorDatabricks.java index 5413ed9d..739470b6 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateTableGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/CreateTableGeneratorDatabricks.java @@ -20,7 +20,7 @@ public class CreateTableGeneratorDatabricks extends CreateTableGenerator { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/GetViewDefinitionGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/GetViewDefinitionGeneratorDatabricks.java index 7335cfa0..17812bd0 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/GetViewDefinitionGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/GetViewDefinitionGeneratorDatabricks.java @@ -18,7 +18,7 @@ public class GetViewDefinitionGeneratorDatabricks extends GetViewDefinitionGener @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/InsertOrUpdateGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/InsertOrUpdateGeneratorDatabricks.java index 95f06e1a..7f2c69dc 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/InsertOrUpdateGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/InsertOrUpdateGeneratorDatabricks.java @@ -20,7 +20,7 @@ public boolean supports(InsertOrUpdateStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java index b57d161c..aaf27e64 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java @@ -24,7 +24,7 @@ public boolean supports(RenameColumnStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameTableGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameTableGeneratorDatabricks.java index 8e582913..9561d62b 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameTableGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameTableGeneratorDatabricks.java @@ -22,7 +22,7 @@ public boolean supports(RenameTableStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameViewGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameViewGeneratorDatabricks.java index 86a22587..54827a58 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameViewGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameViewGeneratorDatabricks.java @@ -22,7 +22,7 @@ public boolean supports(RenameViewStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java index 10e1b05d..1a2b475f 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java @@ -26,7 +26,7 @@ public boolean supports(SetColumnRemarksStatement statement, Database database) @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java index 3cef538b..1f625fd6 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java @@ -21,7 +21,7 @@ public boolean supports(SetTableRemarksStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/UpdateGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/UpdateGeneratorDatabricks.java index 3f30be4d..a455ecfa 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/UpdateGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/UpdateGeneratorDatabricks.java @@ -27,7 +27,7 @@ public boolean supports(UpdateStatement statement, Database database) { @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } diff --git a/src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType b/src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType index 14bb01cc..eeed1de7 100644 --- a/src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType +++ b/src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType @@ -1,10 +1,13 @@ -liquibase.ext.databricks.datatype.DatetimeDatatypeDatabricks +liquibase.ext.databricks.datatype.ArrayIntegerDataTypeDatabricks +liquibase.ext.databricks.datatype.ArrayStringDataTypeDatabricks liquibase.ext.databricks.datatype.BigintDatatypeDatabricks -liquibase.ext.databricks.datatype.StringDatatypeDatabricks -liquibase.ext.databricks.datatype.IntegerDatatypeDatabricks +liquibase.ext.databricks.datatype.BinaryDataTypeDatabricks liquibase.ext.databricks.datatype.BooleanDatatypeDatabricks -liquibase.ext.databricks.datatype.FloatDatatypeDatabricks +liquibase.ext.databricks.datatype.DatetimeDatatypeDatabricks liquibase.ext.databricks.datatype.DoubleDatatypeDatabricks -liquibase.ext.databricks.datatype.TinyintDatatypeDatabricks +liquibase.ext.databricks.datatype.FloatDatatypeDatabricks +liquibase.ext.databricks.datatype.IntegerDatatypeDatabricks liquibase.ext.databricks.datatype.SmallintDatatypeDatabricks -liquibase.ext.databricks.datatype.BinaryDataTypeDatabricks \ No newline at end of file +liquibase.ext.databricks.datatype.StringDatatypeDatabricks +liquibase.ext.databricks.datatype.TimestampDatatypeDatabricks +liquibase.ext.databricks.datatype.TinyintDatatypeDatabricks \ No newline at end of file From 9a0b951c8c9979828ce07a3c148a48bf333fdc4b Mon Sep 17 00:00:00 2001 From: KushnirykOleh Date: Thu, 1 Aug 2024 17:10:16 +0300 Subject: [PATCH 2/4] fixed String datatype --- .../datatype/StringDatatypeDatabricks.java | 6 +-- .../changelogs/databricks/addColumn.xml | 3 +- .../databricks/addColumn.json | 47 +++++++++++++++++++ .../expectedSql/databricks/addColumn.sql | 4 +- 4 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addColumn.json diff --git a/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java index 41fc300d..21c969f5 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/StringDatatypeDatabricks.java @@ -4,7 +4,7 @@ import liquibase.database.Database; import liquibase.datatype.DataTypeInfo; import liquibase.datatype.DatabaseDataType; -import liquibase.datatype.LiquibaseDataType; +import liquibase.datatype.core.VarcharType; import liquibase.ext.databricks.database.DatabricksDatabase; import liquibase.servicelocator.PrioritizedService; @@ -13,9 +13,9 @@ minParameters = 0, maxParameters = 0, priority = PrioritizedService.PRIORITY_DATABASE, - aliases = { "varchar", "clob", "java.lang.String" } + aliases = {"clob", "java.lang.String" } ) -public class StringDatatypeDatabricks extends LiquibaseDataType { +public class StringDatatypeDatabricks extends VarcharType { public StringDatatypeDatabricks() { } diff --git a/src/test/resources/liquibase/harness/change/changelogs/databricks/addColumn.xml b/src/test/resources/liquibase/harness/change/changelogs/databricks/addColumn.xml index b62bf0ef..ea63e630 100644 --- a/src/test/resources/liquibase/harness/change/changelogs/databricks/addColumn.xml +++ b/src/test/resources/liquibase/harness/change/changelogs/databricks/addColumn.xml @@ -6,7 +6,8 @@ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> - + + diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addColumn.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addColumn.json new file mode 100644 index 00000000..a79972ea --- /dev/null +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addColumn.json @@ -0,0 +1,47 @@ +{ + "snapshot": { + "objects": { + "liquibase.structure.core.Table": [ + { + "table": { + "name": "authors" + } + } + ], + "liquibase.structure.core.Column": [ + { + "column": { + "name": "varcharColumn", + "type": { + + "columnSize": "50.*", + "typeName": "VARCHAR" + } + } + }, + { + "column": { + "name": "stringColumn", + "type": { + "columnSize": "255.*", + "typeName": "STRING" + } + } + }, + { + "column": { + "name": "intColumn", + "type": { + "typeName": "INT" + } + } + }, + { + "column": { + "name": "dateColumn" + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addColumn.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addColumn.sql index 206769e9..b8982be3 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addColumn.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addColumn.sql @@ -1,6 +1,8 @@ -ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN varcharColumn STRING +ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN stringColumn STRING +ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN varcharColumn VARCHAR(50) ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN intColumn INT ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN dateColumn date +UPDATE main.liquibase_harness_test_ds.authors SET stringColumn = 'INITIAL_VALUE' UPDATE main.liquibase_harness_test_ds.authors SET varcharColumn = 'INITIAL_VALUE' UPDATE main.liquibase_harness_test_ds.authors SET intColumn = 5 UPDATE main.liquibase_harness_test_ds.authors SET dateColumn = '2023-09-21' \ No newline at end of file From 360dd2e4192e0d63eb917fd9ce583efeaca6e8a4 Mon Sep 17 00:00:00 2001 From: KushnirykOleh Date: Thu, 1 Aug 2024 17:23:15 +0300 Subject: [PATCH 3/4] pulled main --- .../sqlgenerator/AlterTablePropertiesGeneratorDatabricks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AlterTablePropertiesGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AlterTablePropertiesGeneratorDatabricks.java index 3e52a107..db048347 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AlterTablePropertiesGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AlterTablePropertiesGeneratorDatabricks.java @@ -18,7 +18,7 @@ public boolean supports(AlterTablePropertiesStatementDatabricks statement, Datab @Override public int getPriority() { - return DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + return PRIORITY_DATABASE; } @Override From fc45e0d8bd2f8fa42f800e9f144fcf3491f78c55 Mon Sep 17 00:00:00 2001 From: KushnirykOleh Date: Thu, 1 Aug 2024 17:59:44 +0300 Subject: [PATCH 4/4] removed deprecated class --- .../databricks/datatype/TimestampDatatypeDatabricks.java | 4 ++-- .../snapshot/jvm/ViewSnapshotGeneratorDatabricks.java | 4 ++-- .../sqlgenerator/AddColumnGeneratorDatabricks.java | 6 +++--- .../sqlgenerator/RenameColumnGeneratorDatabricks.java | 4 ++-- .../SetColumnRemarksGeneratorDatabricks.java | 9 +++------ .../sqlgenerator/SetTableRemarksGeneratorDatabricks.java | 4 ++-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java b/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java index 5c8d8b06..072c5df8 100644 --- a/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/datatype/TimestampDatatypeDatabricks.java @@ -13,9 +13,9 @@ import liquibase.datatype.DatabaseDataType; import liquibase.exception.DatabaseIncapableOfOperation; import liquibase.servicelocator.PrioritizedService; -import liquibase.util.StringUtil; import liquibase.util.grammar.ParseException; import liquibase.ext.databricks.database.DatabricksDatabase; +import org.apache.commons.lang3.StringUtils; /** * Data type support for TIMESTAMP data types in various DBMS. All DBMS are at least expected to support the @@ -36,7 +36,7 @@ public class TimestampDatatypeDatabricks extends TimestampType { */ @Override public DatabaseDataType toDatabaseDataType(Database database) { - String originalDefinition = StringUtil.trimToEmpty(getRawDefinition()); + String originalDefinition = StringUtils.trimToEmpty(getRawDefinition()); // If a fractional precision is given, check is the DBMS supports the length if (getParameters().length > 0) { Integer desiredLength = null; diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java index 05301ab9..376ef85f 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java @@ -14,13 +14,13 @@ import liquibase.structure.DatabaseObject; import liquibase.structure.core.Schema; import liquibase.structure.core.View; -import liquibase.util.StringUtil; import java.sql.ResultSet; import java.util.List; import java.util.Map; import liquibase.ext.databricks.database.DatabricksDatabase; +import org.apache.commons.lang3.StringUtils; public class ViewSnapshotGeneratorDatabricks extends ViewSnapshotGenerator { @@ -99,7 +99,7 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot definition = definition.substring(0, length - 1); } - definition = StringUtil.trimToNull(definition); + definition = StringUtils.trimToNull(definition); if (definition == null) { definition = "[CANNOT READ VIEW DEFINITION]"; } diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java index d9825d7a..fa64ebeb 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/AddColumnGeneratorDatabricks.java @@ -11,7 +11,7 @@ import liquibase.statement.DatabaseFunction; import liquibase.statement.NotNullConstraint; import liquibase.statement.core.AddColumnStatement; -import liquibase.util.StringUtil; +import org.apache.commons.lang3.StringUtils; import java.util.Iterator; @@ -52,7 +52,7 @@ protected String generateSingleColumnSQL(AddColumnStatement statement, Database ColumnConstraint constraint = var8.next(); if (constraint instanceof NotNullConstraint) { NotNullConstraint notNullConstraint = (NotNullConstraint)constraint; - if (StringUtil.isNotEmpty(notNullConstraint.getConstraintName())) { + if (StringUtils.isNotEmpty(notNullConstraint.getConstraintName())) { alterTable.append(" CONSTRAINT ").append(database.escapeConstraintName(notNullConstraint.getConstraintName())); break; } @@ -75,7 +75,7 @@ protected String generateSingleColumnSQL(AddColumnStatement statement, Database } if (database instanceof MySQLDatabase && statement.getRemarks() != null) { - alterTable.append(" COMMENT '").append(database.escapeStringForDatabase(StringUtil.trimToEmpty(statement.getRemarks()))).append("' "); + alterTable.append(" COMMENT '").append(database.escapeStringForDatabase(StringUtils.trimToEmpty(statement.getRemarks()))).append("' "); } if (statement.getAddBeforeColumn() != null && !statement.getAddBeforeColumn().isEmpty()) { diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java index aaf27e64..be8c688b 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/RenameColumnGeneratorDatabricks.java @@ -12,8 +12,8 @@ import liquibase.statement.core.RenameColumnStatement; import liquibase.structure.core.Column; import liquibase.structure.core.Table; -import liquibase.util.StringUtil; import liquibase.sqlgenerator.core.RenameColumnGenerator; +import org.apache.commons.lang3.StringUtils; public class RenameColumnGeneratorDatabricks extends RenameColumnGenerator { @@ -36,7 +36,7 @@ public ValidationErrors validate(RenameColumnStatement renameColumnStatement, Da validationErrors.checkRequiredField("newColumnName", renameColumnStatement.getNewColumnName()); if (database instanceof MySQLDatabase) { - validationErrors.checkRequiredField("columnDataType", StringUtil.trimToNull(renameColumnStatement.getColumnDataType())); + validationErrors.checkRequiredField("columnDataType", StringUtils.trimToNull(renameColumnStatement.getColumnDataType())); } return validationErrors; diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java index 1a2b475f..3af7b9e6 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetColumnRemarksGeneratorDatabricks.java @@ -3,7 +3,6 @@ import liquibase.ext.databricks.database.DatabricksDatabase; import liquibase.database.Database; import liquibase.database.core.*; -import liquibase.datatype.DataTypeFactory; import liquibase.exception.ValidationErrors; import liquibase.exception.Warnings; import liquibase.sql.Sql; @@ -11,11 +10,9 @@ import liquibase.sqlgenerator.SqlGeneratorChain; import liquibase.statement.core.SetColumnRemarksStatement; import liquibase.structure.core.Column; -import liquibase.structure.core.Data; import liquibase.structure.core.Table; -import liquibase.util.ColumnParentType; -import liquibase.util.StringUtil; import liquibase.sqlgenerator.core.SetColumnRemarksGenerator; +import org.apache.commons.lang3.StringUtils; public class SetColumnRemarksGeneratorDatabricks extends SetColumnRemarksGenerator { @@ -37,7 +34,7 @@ public ValidationErrors validate(SetColumnRemarksStatement setColumnRemarksState validationErrors.checkRequiredField("columnName", setColumnRemarksStatement.getColumnName()); validationErrors.checkDisallowedField("catalogName", setColumnRemarksStatement.getCatalogName(), database, MSSQLDatabase.class); if (database instanceof MySQLDatabase) { - validationErrors.checkRequiredField("columnDataType", StringUtil.trimToNull(setColumnRemarksStatement.getColumnDataType())); + validationErrors.checkRequiredField("columnDataType", StringUtils.trimToNull(setColumnRemarksStatement.getColumnDataType())); } return validationErrors; } @@ -55,7 +52,7 @@ public Warnings warn(SetColumnRemarksStatement statementType, Database database, @Override public Sql[] generateSql(SetColumnRemarksStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { - String remarksEscaped = database.escapeStringForDatabase(StringUtil.trimToEmpty(statement.getRemarks())); + String remarksEscaped = database.escapeStringForDatabase(StringUtils.trimToEmpty(statement.getRemarks())); return new Sql[]{new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) diff --git a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java index 1f625fd6..a7975159 100644 --- a/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/sqlgenerator/SetTableRemarksGeneratorDatabricks.java @@ -9,8 +9,8 @@ import liquibase.statement.core.SetTableRemarksStatement; import liquibase.structure.core.Relation; import liquibase.structure.core.Table; -import liquibase.util.StringUtil; import liquibase.sqlgenerator.core.SetTableRemarksGenerator; +import org.apache.commons.lang3.StringUtils; public class SetTableRemarksGeneratorDatabricks extends SetTableRemarksGenerator { @@ -35,7 +35,7 @@ public ValidationErrors validate(SetTableRemarksStatement setTableRemarksStateme @Override public Sql[] generateSql(SetTableRemarksStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) { String sql; - String remarksEscaped = database.escapeStringForDatabase(StringUtil.trimToEmpty(statement.getRemarks())); + String remarksEscaped = database.escapeStringForDatabase(StringUtils.trimToEmpty(statement.getRemarks())); sql = "COMMENT ON TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) + " IS '" + remarksEscaped + "'";