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-18148: refactorings + tests (#175)
* feat: add support to auto-increment/generated columns * feat: revert changes to auto-increment. * feat: remove useless class * chore(tests): adding tests for default computed values * chore(tests): removing default keyword * chore(tests): empty result to make tests work * added expected json to createTableWithDefaultValues.json --------- Co-authored-by: KushnirykOleh <[email protected]>
- Loading branch information
1 parent
0a3a00b
commit 6099eac
Showing
7 changed files
with
133 additions
and
19 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
10 changes: 7 additions & 3 deletions
10
src/main/java/liquibase/ext/databricks/datatype/BigintDatatypeDatabricks.java
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
2 changes: 0 additions & 2 deletions
2
src/main/java/liquibase/ext/databricks/datatype/DatetimeDatatypeDatabricks.java
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
24 changes: 24 additions & 0 deletions
24
...resources/liquibase/harness/change/changelogs/databricks/createTableWithDefaultValues.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,24 @@ | ||
<?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 author="fl" id="1"> | ||
<createTable tableName="tableWithDefaultValues" > | ||
<column name="longcolumn" type="long" autoIncrement="true" generationType="IDENTITY" /> | ||
<column name="eventTime" type="timestamp"/> | ||
<column name="year" type="int" defaultValueComputed="GENERATED ALWAYS AS (YEAR(eventTime))"/> | ||
<column name="eventDate" type="date" defaultValueComputed="GENERATED ALWAYS AS (CAST(eventTime AS DATE))" /> | ||
<column name="eventDescription" type="string"> | ||
<constraints nullable="false" /> | ||
</column> | ||
<column name="eventShortDescription" type="string" defaultValueComputed="GENERATED ALWAYS AS (SUBSTRING(eventDescription, 0, 1))" /> | ||
</createTable> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
63 changes: 63 additions & 0 deletions
63
...es/liquibase/harness/change/expectedSnapshot/databricks/createTableWithDefaultValues.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,63 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.Table": [ | ||
{ | ||
"table": { | ||
"name": "tableWithDefaultValues" | ||
} | ||
} | ||
], | ||
"liquibase.structure.core.Column": [ | ||
{ | ||
"column": { | ||
"name": "longcolumn", | ||
"type": { | ||
"typeName": "BIGINT" | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "eventTime", | ||
"type": { | ||
"typeName": "TIMESTAMP" | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "year", | ||
"type": { | ||
"typeName": "INT" | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "eventDate", | ||
"type": { | ||
"typeName": "DATE" | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "eventDescription", | ||
"type": { | ||
"typeName": "STRING" | ||
} | ||
} | ||
}, | ||
{ | ||
"column": { | ||
"name": "eventShortDescription", | ||
"type": { | ||
"typeName": "STRING" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...esources/liquibase/harness/change/expectedSql/databricks/createTableWithDefaultValues.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 @@ | ||
CREATE TABLE main.liquibase_harness_test_ds.tableWithDefaultValues (longcolumn LONG GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1), eventTime TIMESTAMP, year INT GENERATED ALWAYS AS (YEAR(eventTime)), eventDate date GENERATED ALWAYS AS (CAST(eventTime AS DATE)), eventDescription STRING NOT NULL, eventShortDescription STRING GENERATED ALWAYS AS (SUBSTRING(eventDescription, 0, 1))) USING delta TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported', 'delta.columnMapping.mode' = 'name', 'delta.enableDeletionVectors' = true) |