Skip to content

Commit

Permalink
adds a fix to type array to databricks, array types used to carry the…
Browse files Browse the repository at this point in the history
…ir size column causing problems when you want to update changeset on databricks, this fix remove fix column same as boolean type
  • Loading branch information
Paulo Dias authored and filipelautert committed Mar 9, 2024
1 parent 81ad11c commit 51460f3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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.ext.databricks.database.DatabricksDatabase;
import liquibase.servicelocator.PrioritizedService;

@DataTypeInfo(
name = "array<string>",
minParameters = 0,
maxParameters = 0,
priority = PrioritizedService.PRIORITY_DATABASE
)
public class ArrayDatatypeDatabricks extends LiquibaseDataType {

public ArrayDatatypeDatabricks() {
// empty constructor
}

@Override
public boolean supports(Database database) {
return database instanceof DatabricksDatabase;
}

@Override
public DatabaseDataType toDatabaseDataType(Database database) {
if (database instanceof DatabricksDatabase) {

DatabaseDataType type = new DatabaseDataType("ARRAY<STRING>", this.getParameters());
type.setType("ARRAY<STRING>");
return type;
} else {
return super.toDatabaseDataType(database);
}

}

public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() {
return LoadDataChange.LOAD_DATA_TYPE.STRING;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ liquibase.ext.databricks.datatype.IntegerDatatypeDatabricks
liquibase.ext.databricks.datatype.BooleanDatatypeDatabricks
liquibase.ext.databricks.datatype.FloatDatatypeDatabricks
liquibase.ext.databricks.datatype.DoubleDatatypeDatabricks
liquibase.ext.databricks.datatype.ArrayDatatypeDatabricks

0 comments on commit 51460f3

Please sign in to comment.