generated from liquibase/liquibase-extension-example
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DAT-18149] Add cluster columns (#177)
* Add databricks:clusterColumns element * Add YAML and JSON cluster columns examples * Add drop clustered column example * Update changelogs to be identical to XML
- Loading branch information
1 parent
bc9387f
commit 9148023
Showing
7 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...est/resources/liquibase/harness/change/changelogs/databricks/createClusteredTableNew.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"databaseChangeLog": [ | ||
{ | ||
"changeSet": { | ||
"id": "1", | ||
"author": "your.name", | ||
"changes": [ | ||
{ | ||
"createTable": { | ||
"tableName": "test_table_clustered_new", | ||
"columns": [ | ||
{ | ||
"column": { | ||
"name": "test_id", | ||
"type": "int" | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "test_new", | ||
"type": "int" | ||
} | ||
} | ||
], | ||
"clusterColumns": "test_id,test_new" | ||
} | ||
} | ||
], | ||
"rollback": [ | ||
{ | ||
"dropTable": { | ||
"tableName": "test_table_clustered_new" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"changeSet":{ | ||
"id": 2, | ||
"author":"your.name", | ||
"changes":[ | ||
{ | ||
"alterCluster": { | ||
"tableName": "test_table_clustered_new", | ||
"columns": [ | ||
{ | ||
"column": { | ||
"name": "test_id" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"rollback": [ | ||
{ | ||
"empty": { | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"changeSet": { | ||
"id": 3, | ||
"author": "your.name", | ||
"changes": [ | ||
{ | ||
"dropColumn": { | ||
"columnName": "test_new", | ||
"tableName": "test_table_clustered_new" | ||
} | ||
} | ||
], | ||
"rollback": [ | ||
{ | ||
"empty": { | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
34 changes: 34 additions & 0 deletions
34
...test/resources/liquibase/harness/change/changelogs/databricks/createClusteredTableNew.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:databricks="http://www.liquibase.org/xml/ns/databricks" | ||
|
||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd | ||
http://www.liquibase.org/xml/ns/databricks | ||
http://www.liquibase.org/xml/ns/databricks/liquibase-databricks-latest.xsd"> | ||
|
||
<changeSet id="1" author="as"> | ||
<createTable tableName="test_table_clustered_new" > | ||
<column name="test_id" type="int" /> | ||
<column name="test_new" type="int"/> | ||
<databricks:clusterColumns>test_id,test_new</databricks:clusterColumns> | ||
</createTable> | ||
<rollback> | ||
<!-- The dropTable will drop a full table whether it has clustered columns or not. --> | ||
<dropTable tableName="test_table_clustered_new"/> | ||
</rollback> | ||
</changeSet> | ||
<changeSet id="2" author="your.name"> | ||
<databricks:alterCluster tableName="test_table_clustered_new"> | ||
<databricks:column name="test_id"/> | ||
</databricks:alterCluster> | ||
<rollback/> | ||
</changeSet> | ||
<changeSet id="3" author="your.name"> | ||
<!-- The Databricks does not allow clustered columns to be dropped, so they should be unclustered before the dropColumn in the alterCluster. --> | ||
<dropColumn tableName="test_table_clustered_new" columnName="test_new"/> | ||
<rollback/> | ||
</changeSet> | ||
</databaseChangeLog> |
38 changes: 38 additions & 0 deletions
38
...est/resources/liquibase/harness/change/changelogs/databricks/createClusteredTableNew.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
databaseChangeLog: | ||
- changeSet: | ||
id: 1 | ||
author: your.name | ||
changes: | ||
- createTable: | ||
tableName: test_table_clustered_new | ||
columns: | ||
- column: | ||
name: test_id | ||
type: int | ||
- column: | ||
name: test_new | ||
type: int | ||
clusterColumns: test_id, test_new | ||
rollback: | ||
dropTable: | ||
tableName: test_table_clustered_new | ||
- changeSet: | ||
id: 2 | ||
author: your.name | ||
changes: | ||
- alterCluster: | ||
tableName: test_table_clustered_new | ||
columns: | ||
- column: | ||
name: test_id | ||
rollback: | ||
empty | ||
- changeSet: | ||
id: 3 | ||
author: your.name | ||
changes: | ||
- dropColumn: | ||
columnName: test_new | ||
tableName: test_table_clustered_new | ||
rollback: | ||
empty |
2 changes: 2 additions & 0 deletions
2
...sources/liquibase/harness/change/expectedSnapshot/databricks/createClusteredTableNew.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
3 changes: 3 additions & 0 deletions
3
...est/resources/liquibase/harness/change/expectedSql/databricks/createClusteredTableNew.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE TABLE main.liquibase_harness_test_ds.test_table_clustered_new (test_id INT, test_new INT) USING delta TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported', 'delta.columnMapping.mode' = 'name', 'delta.enableDeletionVectors' = true) CLUSTER BY (test_id, test_new) | ||
ALTER TABLE main.liquibase_harness_test_ds.test_table_clustered_new CLUSTER BY (test_id) | ||
ALTER TABLE main.liquibase_harness_test_ds.test_table_clustered_new DROP COLUMN test_new |