This is the Liquibase Extension for Managing Delta Tables on DatabricksSQL.
Base/Contributed and Foundational Change types should be supported at this stage. Change types such as procedures, triggers, sequences, indexes are not supported. Databricks specific change types that are added are listed below along with their completion status. Databricks tables creates with liquibase are automatically created with the Delta configs / versions that are required for all passing change types including: 'delta.feature.allowColumnDefaults' = 'supported', 'delta.columnMapping.mode' = 'name'
This extension utilizes Unity Catalog System tables for many advanced operations such as snapshotting, identifying various constraints (PK/FK/NOT NULL, etc.) If hive_metastore is used, this is not tested and may not provide all the below functionality.
- Add unit tests with liquibase test harness - Cody Davis - DONE
- Pass Foundational Test Harness - Cody Davis - DONE 4/1/2023
- Pass Contributed Test Harness - Cody Davis - DONE 9/15/2023
- Pass Advanced Test Harness - Cody Davis - DONE 9/28/2023
- createTable/dropTable
- addColumn/dropColumn
- addPrimaryKey/dropPrimaryKey
- addForeignKey/dropForeignKey
- addNotNullConstraint/dropNotNullConstraint
- createTable/createTableDataTypeText/createTableTimestamp/dropTable
- createView/dropView
- dropAllForeignKeyConstraints
- createView/dropView
- setTableRemarks - supported but not returned in snapshot as JDBC Driver not populating it
- setColumnRemarks
- setViewRemarks (set in TBLPROPERTIES ('comment' = ''))
- executeCommand
- mergeColumns
- modifySql
- renameColumn
- renameView
- sql
- sqlFile
- Change Data Test: apply delete
- Change Data Test: apply insert
- Change Data Test: apply loadData
- Change Data Test: apply loadDataUpdate
- Add/Drop Check Constraints - supported but not returned in snapshot
- addColumn snapshot
- addPrimaryKey snapshot
- addForeignKey snapshot
- schemaAndCatalogSnapshot snapshot
- createTable snapshot
- createView snapshot
- generateChangelog -
- addUniqueConstraint - not supported
- createIndex - Not Supported, use changeClusterColumns change type for datbricks to Map to CLUSTER BY ALTER TABLE statements for Delta Tables
- alterTableProperties
- alterCluster
- OPTIMIZE - optimizeTable - optimize with zorderCols options - SUPPORTED in Contributed Harness
- CLUSTER BY (DDL) - createClusteredTable - createTable with clusterColumns as additional option for liquid - SUPPORTED in Contributed Harness
- ANALYZE TABLE - analyzeTable - change type with compute stats column options - SUPPORTED in Contributed Harness
- VACUUM - vacuumTable - change type with retentionHours parameter (default is 168) - SUPPORTED in Contributed Harness
- ALTER CLUSTER KEY - alterCluster - change type that will be used until index change types are mapped with CLUSTER BY columns for snapshot purposes
- (nice to have, not required) createFunction/dropFunction - in Liquibase Pro, should work in Databricks, but change type not accessible from Liquibase Core
- (nice to have, not required) addCheckConstraint/dropCheckConstraint - in Liquibase Pro, should work in Databricks, but change type not accessible from Liquibase Core
- addDefaultValue (of various types). Databricks/Delta tables support this, but does not get populated by databricks in the JDBC Driver (COLUMN_DEF property always None even with default) The remaining other change types are not relevant to Databricks and have been marked with INVALID TEST
- Add support for Snapshotting complex types like STRUCT/MAP
- Add support for snapshotting IDENTITY KEYs
- Add TIMESTAMP_NTZ Data Type
- COPY INTO
- MERGE
- RESTORE VERSION AS OF
- ANALYZE TABLE - Code Complete - Adding Tests - Cody Davis
- CLONE
- BLOOM FILTERS - Maybe do not support, CLUSTER BY should be the primary indexing mechanism long term
- OPTIMIZE / ZORDER - Code Complete - Adding Tests - Cody Davis
- VACUUM - Code Complete - Adding Tests - Cody Davis
- SYNC IDENTITY
- VOLUMES
- GRANT / REVOKE statements
-
Download and install liquibase from here
-
Download the Databricks Driver from here. Then put this driver jar under the liquibase/lib directory.
-
Build this project or retrieve the jar from the latest release. Then put this extension jar under the liquibase/lib directory.
-
IMPORTANT: If using Linux/MaxOS - run the following command in your terminal before continuing (you can add this to the bash/zsh profile): export JAVA_OPTS=--add-opens=java.base/java.nio=ALL-UNNAMED
-
Edit the connection parameters to your Databricks catlaog/database under the liquibase.properties file. The format will look like this:
url: jdbc:databricks://<workspace_url>:443/default;transportMode=http;ssl=1;httpPath=<http_path>;AuthMech=3;ConnCatalog=<catalog>;ConnSchema=<database>;
username: token
password: <dbx_token>
Where the following parameters are:
- Add changes and run your change logs like so:
liquibase --changeLogFile=changelog.sql update