Skip to content

Commit

Permalink
[DAT-18788] adding Location to snapshot, but not to generated changel…
Browse files Browse the repository at this point in the history
…og (#200)

* wip

* reverted ColumnSnapshotGeneratorDatabricks, it went to DAT-18790

* wip

* added missingTable generator

* addressed PR comment

* resolved Sonar issues

* fixed exception when DBCL is missing

* adding location only if type=External

* removed location from changelog, but always have it in snapshot

* removed unused fields, updated test
  • Loading branch information
KushnirykOleh authored Oct 16, 2024
1 parent 0a99801 commit 065dbe4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public Change[] fixMissing(DatabaseObject missingObject, DiffOutputControl contr
if (changes == null || changes.length == 0) {
return changes;
}
//so far we intentionally omit tableLocation in generated changelog
ExtendedTableProperties extendedTableProperties = new ExtendedTableProperties(
missingObject.getAttribute("Location", String.class),
null,
missingObject.getAttribute("tblProperties", String.class));

changes[0] = getCreateTableChangeDatabricks(extendedTableProperties, changes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot
}
return table;
}
//TODO another way of getting Location is query like
// select * from `system`.`information_schema`.`tables` where table_name = 'test_table_properties' AND table_schema='liquibase_harness_test_ds';
// get column 'table_type', if 'EXTERNAL' then
// Location = get column 'storage_path'
// cleanup this after approach of getting all properties is settled

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<column name="test_id" type="int">
<constraints primaryKey="true" nullable="false"/>
</column>
<databricks:extendedTableProperties tblProperties="'external.location'='s3://mybucket/mytable','this.is.my.key'=12,'this.is.my.key2'=true"/>
<databricks:extendedTableProperties tblProperties="'this.is.my.key'=12,'this.is.my.key2'=true"
tableLocation="s3://databricks-th/test_table_properties"/>
</createTable>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{
"table": {
"name": "test_table_properties",
"tblProperties" : "delta.checkpoint.writeStatsAsJson=false,delta.checkpoint.writeStatsAsStruct=true,delta.enableDeletionVectors=true,delta.feature.deletionVectors=supported,delta.feature.invariants=supported,delta.minReaderVersion=3,delta.minWriterVersion=7,external.location=s3://mybucket/mytable,this.is.my.key=12,this.is.my.key2=true"
"Location" : "s3://databricks-th/test_table_properties",
"tblProperties" : "delta.checkpoint.writeStatsAsJson=false,delta.checkpoint.writeStatsAsStruct=true,delta.enableDeletionVectors=true,delta.feature.deletionVectors=supported,delta.feature.invariants=supported,delta.minReaderVersion=3,delta.minWriterVersion=7,this.is.my.key=12,this.is.my.key2=true"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE main.liquibase_harness_test_ds.test_table (test_id INT NOT NULL, test_column VARCHAR(50) NOT NULL, CONSTRAINT PK_TEST_TABLE PRIMARY KEY (test_id)) USING delta TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported', 'delta.columnMapping.mode' = 'name', 'delta.enableDeletionVectors' = true)
CREATE TABLE main.liquibase_harness_test_ds.test_table_properties (test_id INT NOT NULL, CONSTRAINT PK_TEST_TABLE_PROPERTIES PRIMARY KEY (test_id)) TBLPROPERTIES ('external.location'='s3://mybucket/mytable','this.is.my.key'=12,'this.is.my.key2'=true)
CREATE TABLE main.liquibase_harness_test_ds.test_table_properties (test_id INT NOT NULL, CONSTRAINT PK_TEST_TABLE_PROPERTIES PRIMARY KEY (test_id)) TBLPROPERTIES ('this.is.my.key'=12,'this.is.my.key2'=true) LOCATION 's3://databricks-th/test_table_properties'

0 comments on commit 065dbe4

Please sign in to comment.