diff --git a/src/main/java/liquibase/ext/databricks/diff/output/changelog/ChangedTblPropertiesUtil.java b/src/main/java/liquibase/ext/databricks/diff/output/changelog/ChangedTblPropertiesUtil.java index 6c0897c..c402dac 100644 --- a/src/main/java/liquibase/ext/databricks/diff/output/changelog/ChangedTblPropertiesUtil.java +++ b/src/main/java/liquibase/ext/databricks/diff/output/changelog/ChangedTblPropertiesUtil.java @@ -50,8 +50,8 @@ static AbstractAlterPropertiesChangeDatabricks[] getAlterTablePropertiesChangeDa static AbstractAlterPropertiesChangeDatabricks[] getAbstractTablePropertiesChangeDatabricks(AbstractDatabaseObject changedObject, DiffOutputControl control, Difference difference, Class clazz) { AbstractAlterPropertiesChangeDatabricks[] changes = new AbstractAlterPropertiesChangeDatabricks[0]; - Map referencedValuesMap = convertToMap(difference.getReferenceValue()); - Map comparedValuesMap = convertToMap(difference.getComparedValue()); + Map referencedValuesMap = convertToMapExcludingDeltaParameters(difference.getReferenceValue()); + Map comparedValuesMap = convertToMapExcludingDeltaParameters(difference.getComparedValue()); Map addPropertiesMap = new HashMap<>(); //first we add the missing or changed properties @@ -89,7 +89,10 @@ static AbstractAlterPropertiesChangeDatabricks[] getAbstractTablePropertiesChang return changes; } - private static Map convertToMap(Object referenceValueObject) { + /** + * Convert the reference value to a map excluding delta parameters + */ + private static Map convertToMapExcludingDeltaParameters(Object referenceValueObject) { String referenceValue = referenceValueObject == null ? "" : referenceValueObject.toString(); return Arrays.stream(referenceValue.split(SPLIT_ON_COMMAS)) .map(s -> s.split(SPLIT_ON_EQUALS)) @@ -99,6 +102,14 @@ private static Map convertToMap(Object referenceValueObject) { .collect(Collectors.toMap(a -> a[0], a -> a[1])); } + /** + * Get the extended properties excluding delta parameters + */ + public static String getExtendedProperties(String tblProperties) { + Map properties = convertToMapExcludingDeltaParameters(tblProperties); + return properties.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(",")); + } + private static AbstractAlterPropertiesChangeDatabricks getAbstractAlterPropertiesChangeDatabricks(AbstractDatabaseObject changedObject, DiffOutputControl control, Class clazz) { AbstractAlterPropertiesChangeDatabricks change; try { diff --git a/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingTableChangeGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingTableChangeGeneratorDatabricks.java index 27b922d..ab5cf2c 100644 --- a/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingTableChangeGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingTableChangeGeneratorDatabricks.java @@ -12,6 +12,8 @@ import liquibase.structure.DatabaseObject; import liquibase.structure.core.Table; +import static liquibase.ext.databricks.diff.output.changelog.ChangedTblPropertiesUtil.getExtendedProperties; + public class MissingTableChangeGeneratorDatabricks extends MissingTableChangeGenerator { @Override @@ -33,7 +35,7 @@ public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl contr //so far we intentionally omit tableLocation in generated changelog ExtendedTableProperties extendedTableProperties = new ExtendedTableProperties( null, - missingObject.getAttribute("tblProperties", String.class)); + getExtendedProperties(missingObject.getAttribute("tblProperties", String.class))); String clusterColumns = missingObject.getAttribute("clusteringColumns", ""); changes[0] = getCreateTableChangeDatabricks(extendedTableProperties, changes, clusterColumns); @@ -65,4 +67,4 @@ private CreateTableChangeDatabricks getCreateTableChangeDatabricks(ExtendedTable protected CreateTableChange createCreateTableChange() { return new CreateTableChangeDatabricks(); } -} \ No newline at end of file +} diff --git a/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingViewChangeGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingViewChangeGeneratorDatabricks.java index 43d856c..f94275f 100644 --- a/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingViewChangeGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/diff/output/changelog/MissingViewChangeGeneratorDatabricks.java @@ -11,6 +11,8 @@ import liquibase.structure.DatabaseObject; import liquibase.structure.core.View; +import static liquibase.ext.databricks.diff.output.changelog.ChangedTblPropertiesUtil.getExtendedProperties; + /** * Custom implementation of {@link MissingViewChangeGenerator} for Databricks. */ @@ -31,7 +33,7 @@ public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl contr if (changes == null || changes.length == 0) { return changes; } - changes[0] = getCreateViewChangeDatabricks(missingObject.getAttribute("tblProperties", String.class), changes); + changes[0] = getCreateViewChangeDatabricks(getExtendedProperties(missingObject.getAttribute("tblProperties", String.class)), changes); return changes; }