From 04ed4dd57a676ba65525e324371e696316e7a835 Mon Sep 17 00:00:00 2001 From: Mykhailo Savchenko Date: Wed, 8 Jan 2025 16:53:27 +0200 Subject: [PATCH] DAT-19349: added missing supported snapshot data to the harness ChangeObjectTests related files, update some expected snapshots. Updated some descriptions, enabled different default value tests. --- .../databricks/addCheckConstraint.json | 13 +++++++++- .../databricks/addDefaultValue.json | 24 +++++++++++++++++++ .../databricks/addDefaultValueBoolean.json | 17 +++++++++++++ .../databricks/addDefaultValueComputed.json | 18 ++++++++++++++ .../databricks/addDefaultValueDate.json | 18 ++++++++++++++ .../databricks/alterCluster.json | 12 ++++++++++ .../databricks/alterTableProperties.json | 13 +++++++++- .../databricks/alterViewProperties.json | 13 +++++++++- .../databricks/createClusteredTable.json | 3 ++- .../databricks/createPartitionedTable.json | 3 ++- .../databricks/dropCheckConstraint.json | 15 +++++++++++- .../databricks/addDefaultValue.sql | 4 +--- .../databricks/addDefaultValueBoolean.sql | 5 ++-- .../databricks/addDefaultValueComputed.sql | 3 +-- .../databricks/addDefaultValueDate.sql | 5 ++-- .../databricks/addDefaultValueNumeric.sql | 5 ++-- .../addDefaultValueSequenceNext.sql | 3 ++- .../expectedSql/databricks/createFunction.sql | 2 +- .../expectedSql/databricks/enableTrigger.sql | 2 +- .../expectedSql/databricks/renameTrigger.sql | 2 +- 20 files changed, 157 insertions(+), 23 deletions(-) create mode 100644 src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValue.json create mode 100644 src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueBoolean.json create mode 100644 src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueComputed.json create mode 100644 src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueDate.json diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addCheckConstraint.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addCheckConstraint.json index 0e0dcd23..fa21e6ac 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addCheckConstraint.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addCheckConstraint.json @@ -1,3 +1,14 @@ { - + "snapshot": { + "objects": { + "liquibase.structure.core.Table": [ + { + "table": { + "name": "posts", + "tblProperties": ".*'delta.constraints.test_check_constraint'='id > 0'.*" + } + } + ] + } + } } \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValue.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValue.json new file mode 100644 index 00000000..7a2b16c5 --- /dev/null +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValue.json @@ -0,0 +1,24 @@ +{ + "snapshot": { + "objects": { + "liquibase.structure.core.Table": [ + { + "table": { + "name": "posts" + } + } + ], + "liquibase.structure.core.Column": [ + { + "column": { + "name": "title", + "type": { + "typeName": "VARCHAR" + }, + "defaultValue": "title_test" + } + } + ] + } + } +} diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueBoolean.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueBoolean.json new file mode 100644 index 00000000..1a9d455f --- /dev/null +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueBoolean.json @@ -0,0 +1,17 @@ +{ + "snapshot": { + "objects": { + "liquibase.structure.core.Column": [ + { + "column": { + "name": "booleanColumn", + "type": { + "typeName": "BOOLEAN" + }, + "defaultValue": "TRUE" + } + } + ] + } + } +} diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueComputed.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueComputed.json new file mode 100644 index 00000000..337ec62d --- /dev/null +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueComputed.json @@ -0,0 +1,18 @@ +{ + "snapshot": { + "objects": { + "liquibase.structure.core.Column": [ + { + "column": { + "name": "inserted_date", + "type": { + "typeName": "DATE" + }, + "defaultValue": "CURRENT_TIMESTAMP", + "nullable": true + } + } + ] + } + } +} diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueDate.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueDate.json new file mode 100644 index 00000000..5ab9909a --- /dev/null +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/addDefaultValueDate.json @@ -0,0 +1,18 @@ +{ + "snapshot": { + "objects": { + "liquibase.structure.core.Column": [ + { + "column": { + "name": "dateTimeColumn", + "type": { + "typeName": "TIMESTAMP" + }, + "defaultValue": "'2008-02-12 12:34:03'", + "nullable": true + } + } + ] + } + } +} diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterCluster.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterCluster.json index 7a73a41b..f4adcc85 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterCluster.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterCluster.json @@ -1,2 +1,14 @@ { + "snapshot": { + "objects": { + "liquibase.structure.core.Table": [ + { + "table": { + "name": "test_table_alter_cluster", + "clusteringColumns": "test_id,test_new" + } + } + ] + } + } } \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterTableProperties.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterTableProperties.json index 0e0dcd23..2432decd 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterTableProperties.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterTableProperties.json @@ -1,3 +1,14 @@ { - + "snapshot": { + "objects": { + "liquibase.structure.core.Table": [ + { + "table": { + "name": "test_alter_table_properties", + "tblProperties": ".*'external.location'='s3://mybucket/mytable', 'this.is.my.key'='12', 'this.is.my.key2'='true'.*" + } + } + ] + } + } } \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterViewProperties.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterViewProperties.json index 0e0dcd23..d4566e62 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterViewProperties.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/alterViewProperties.json @@ -1,3 +1,14 @@ { - + "snapshot": { + "objects": { + "liquibase.structure.core.View": [ + { + "view": { + "name": "test_alter_view_properties", + "tblProperties": ".*'external.location'='s3://mybucket/mytable', 'this.is.my.key'='12', 'this.is.my.key2'='true'.*" + } + } + ] + } + } } \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createClusteredTable.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createClusteredTable.json index f2037e5e..6633b45f 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createClusteredTable.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createClusteredTable.json @@ -4,7 +4,8 @@ "liquibase.structure.core.Table": [ { "table": { - "name": "test_table_clustered" + "name": "test_table_clustered", + "clusteringColumns": "test_id" } } ], diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createPartitionedTable.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createPartitionedTable.json index 06db8b4e..987dd98d 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createPartitionedTable.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/createPartitionedTable.json @@ -4,7 +4,8 @@ "liquibase.structure.core.Table": [ { "table": { - "name": "test_table_partitioned" + "name": "test_table_partitioned", + "partitionColumns": "partition_column" } } ], diff --git a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/dropCheckConstraint.json b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/dropCheckConstraint.json index 0e0dcd23..3afdbd38 100644 --- a/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/dropCheckConstraint.json +++ b/src/test/resources/liquibase/harness/change/expectedSnapshot/databricks/dropCheckConstraint.json @@ -1,3 +1,16 @@ { - + "snapshot": { + "objects": { + "_noMatch": true, + "_noMatchField": "tblProperties", + "liquibase.structure.core.Table": [ + { + "table": { + "name": "posts", + "tblProperties": ".*'delta.constraints.test_check_constraint'='id > 0'.*" + } + } + ] + } + } } \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValue.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValue.sql index e119a4e4..916ac80e 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValue.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValue.sql @@ -1,3 +1 @@ -INVALID TEST --- Databricks supports default values, but does not support them in snapshot data json ---ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN title SET DEFAULT 'title_test' \ No newline at end of file +ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN title SET DEFAULT 'title_test' \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueBoolean.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueBoolean.sql index b15e44d3..ea48395d 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueBoolean.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueBoolean.sql @@ -1,3 +1,2 @@ -INVALID TEST --- Databricks supports default values, but the object does not exist in the metadata --- --ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN title SET DEFAULT false \ No newline at end of file +ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN booleanColumn BOOLEAN +ALTER TABLE main.liquibase_harness_test_ds.authors ALTER COLUMN booleanColumn SET DEFAULT TRUE \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueComputed.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueComputed.sql index 2fc5bfcd..543d9f73 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueComputed.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueComputed.sql @@ -1,2 +1 @@ -INVALID TEST --- Databricks supports default values and generated columns, but the object does not exist in the metadata returned in jdbc \ No newline at end of file +ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN inserted_date SET DEFAULT CURRENT_TIMESTAMP \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueDate.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueDate.sql index 8f32c3ff..22c1c464 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueDate.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueDate.sql @@ -1,3 +1,2 @@ -INVALID TEST --- Databricks supports default values, but the object does not exist in the metadata ---ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN title SET DEFAULT false \ No newline at end of file +ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN dateTimeColumn TIMESTAMP +ALTER TABLE main.liquibase_harness_test_ds.authors ALTER COLUMN dateTimeColumn SET DEFAULT '2008-02-12 12:34:03' \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueNumeric.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueNumeric.sql index 8f32c3ff..a3bc217f 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueNumeric.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueNumeric.sql @@ -1,3 +1,4 @@ INVALID TEST --- Databricks supports default values, but the object does not exist in the metadata ---ALTER TABLE main.liquibase_harness_test_ds.posts ALTER COLUMN title SET DEFAULT false \ No newline at end of file +-- Databricks does not support NUMBER type +-- ALTER TABLE main.liquibase_harness_test_ds.authors ADD COLUMN numericColumn NUMBER +-- ALTER TABLE main.liquibase_harness_test_ds.authors ALTER COLUMN numericColumn SET DEFAULT 100000000 \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueSequenceNext.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueSequenceNext.sql index 47bbf2b5..79ce09df 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueSequenceNext.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/addDefaultValueSequenceNext.sql @@ -1 +1,2 @@ -INVALID TEST \ No newline at end of file +INVALID TEST +--Database databricks does not support sequences \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/createFunction.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/createFunction.sql index 2e1258c4..424e1303 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/createFunction.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/createFunction.sql @@ -1,2 +1,2 @@ INVALID TEST --- Databricks supports functions, but this can only be done in liquibase PRO \ No newline at end of file +-- Databricks supports functions, but this can only be done in Databricks commercial extension \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/enableTrigger.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/enableTrigger.sql index e884ddc9..6f3e3c03 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/enableTrigger.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/enableTrigger.sql @@ -1,2 +1,2 @@ INVALID TEST -Databricks does not support the concept of triggers \ No newline at end of file +--Databricks does not support the concept of triggers \ No newline at end of file diff --git a/src/test/resources/liquibase/harness/change/expectedSql/databricks/renameTrigger.sql b/src/test/resources/liquibase/harness/change/expectedSql/databricks/renameTrigger.sql index e884ddc9..6f3e3c03 100644 --- a/src/test/resources/liquibase/harness/change/expectedSql/databricks/renameTrigger.sql +++ b/src/test/resources/liquibase/harness/change/expectedSql/databricks/renameTrigger.sql @@ -1,2 +1,2 @@ INVALID TEST -Databricks does not support the concept of triggers \ No newline at end of file +--Databricks does not support the concept of triggers \ No newline at end of file