-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Allow writing to Delta Lake tables using writer v3 #14068
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -334,11 +334,11 @@ public void testCheckConstraintsCompatibility() | |
| .containsOnly(row(1, 1)); | ||
|
|
||
| assertQueryFailure(() -> onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (2, 2)")) | ||
| .hasMessageMatching(".*Table default." + tableName + " requires Delta Lake writer version 3 which is not supported"); | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| assertQueryFailure(() -> onTrino().executeQuery("DELETE FROM delta.default." + tableName + " WHERE a_number = 1")) | ||
| .hasMessageMatching(".*Table default." + tableName + " requires Delta Lake writer version 3 which is not supported"); | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| assertQueryFailure(() -> onTrino().executeQuery("UPDATE delta.default." + tableName + " SET a_number = 10 WHERE id = 1")) | ||
| .hasMessageMatching(".*Table default." + tableName + " requires Delta Lake writer version 3 which is not supported"); | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
|
|
||
| assertThat(onTrino().executeQuery("SELECT id, a_number FROM " + tableName)) | ||
| .containsOnly(row(1, 1)); | ||
|
|
@@ -469,4 +469,51 @@ public Object[][] compressionCodecs() | |
| {"GZIP"}, | ||
| }; | ||
| } | ||
|
|
||
| @Test(groups = {DELTA_LAKE_OSS, DELTA_LAKE_DATABRICKS, DELTA_LAKE_EXCLUDE_73, PROFILE_SPECIFIC_TESTS}) | ||
| public void testWritesToTableWithCheckConstraintFails() | ||
| { | ||
| String tableName = "test_writes_into_table_with_check_constraint_" + randomTableSuffix(); | ||
| try { | ||
| onDelta().executeQuery("CREATE TABLE default." + tableName + " (a INT, b INT) " + | ||
| "USING DELTA " + | ||
| "LOCATION 's3://" + bucketName + "/databricks-compatibility-test-" + tableName + "'"); | ||
| onDelta().executeQuery("ALTER TABLE default." + tableName + " ADD CONSTRAINT aIsPositive CHECK (a > 0)"); | ||
|
|
||
| assertQueryFailure(() -> onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (1, 2)")) | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| assertQueryFailure(() -> onTrino().executeQuery("UPDATE delta.default." + tableName + " SET a = 3 WHERE b = 3")) | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| assertQueryFailure(() -> onTrino().executeQuery("DELETE FROM delta.default." + tableName + " WHERE a = 3")) | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| assertQueryFailure(() -> onTrino().executeQuery("MERGE INTO delta.default." + tableName + " t USING delta.default." + tableName + " s " + | ||
| "ON (t.a = s.a) WHEN MATCHED THEN UPDATE SET b = 42")) | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
| } | ||
| finally { | ||
| onDelta().executeQuery("DROP TABLE IF EXISTS default." + tableName); | ||
| } | ||
| } | ||
|
|
||
| @Test(groups = {DELTA_LAKE_OSS, DELTA_LAKE_DATABRICKS, DELTA_LAKE_EXCLUDE_73, PROFILE_SPECIFIC_TESTS}) | ||
| public void testMetadataOperationsRetainCheckConstraints() | ||
| { | ||
| String tableName = "test_metadata_operations_retain_check_constraints_" + randomTableSuffix(); | ||
| try { | ||
| onDelta().executeQuery("CREATE TABLE default." + tableName + " (a INT, b INT) " + | ||
| "USING DELTA " + | ||
| "LOCATION 's3://" + bucketName + "/databricks-compatibility-test-" + tableName + "'"); | ||
| onDelta().executeQuery("ALTER TABLE default." + tableName + " ADD CONSTRAINT aIsPositive CHECK (a > 0)"); | ||
|
|
||
| onTrino().executeQuery("ALTER TABLE delta.default." + tableName + " ADD COLUMN c INT"); | ||
| onTrino().executeQuery("COMMENT ON COLUMN delta.default." + tableName + ".c IS 'example column comment'"); | ||
| onTrino().executeQuery("COMMENT ON TABLE delta.default." + tableName + " IS 'example table comment'"); | ||
|
|
||
| assertQueryFailure(() -> onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (1, 2, 3)")) | ||
| .hasMessageContaining("Writing to tables with CHECK constraints is not supported"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are missing a test for MERGE here ;) |
||
| } | ||
| finally { | ||
| onDelta().executeQuery("DROP TABLE IF EXISTS default." + tableName); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to disable
DELETEwhen a table has check constraints? Is there any situation deleting rows violate check constraints?I'm fine with disallowing it because allowing only
DELETElooks not useful. Just asking to understand the context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be safe to enable as long as the check constraints are only row by row. I think I'd opt to leave it disabled for now though and we can enable it when we come back and take a closer look at supporting check constraints.