Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DAT-18149] Add cluster columns #177

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@
<xsd:enumeration value="true"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="clusterColumns" type="xsd:string"/>

</xsd:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@
<xsd:enumeration value="true"/>
</xsd:restriction>
</xsd:simpleType>

<xsd:element name="clusterColumns" type="xsd:string"/>

</xsd:schema>
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": {
}
}
]
}
}
]
}
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>
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
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
Loading