Skip to content

Commit

Permalink
Add test for unknown evaluations for Delta check constrains
Browse files Browse the repository at this point in the history
  • Loading branch information
pajaks authored and ebyhr committed Apr 26, 2023
1 parent 1dd8893 commit 9161ee7
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ public static Object[][] checkConstraints()
};
}

@Test(groups = {DELTA_LAKE_DATABRICKS, DELTA_LAKE_OSS, DELTA_LAKE_EXCLUDE_73, PROFILE_SPECIFIC_TESTS})
@Flaky(issue = DATABRICKS_COMMUNICATION_FAILURE_ISSUE, match = DATABRICKS_COMMUNICATION_FAILURE_MATCH)
public void testCheckConstraintUnknownCondition()
{
String tableName = "test_check_constraint_unknown_" + randomNameSuffix();

onDelta().executeQuery("CREATE TABLE default." + tableName +
"(a INT) " +
"USING DELTA " +
"LOCATION 's3://" + bucketName + "/databricks-compatibility-test-" + tableName + "'");
onDelta().executeQuery("ALTER TABLE default." + tableName + " ADD CONSTRAINT a_constraint CHECK (a > 1)");

try {
// Values which produces unknown conditions are treated as FALSE by DELTA specification and as TRUE by Trino according to SQL standard
// https://github.com/delta-io/delta/issues/1714
assertThatThrownBy(() -> onDelta().executeQuery("INSERT INTO default." + tableName + " VALUES (null)"))
.hasMessageMatching("(?s).* CHECK constraint .* violated by row with values.*");

onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (null)");
assertThat(onTrino().executeQuery("SELECT * FROM delta.default." + tableName))
.containsOnly(row((Object) null));
}
finally {
dropDeltaTableWithRetry("default." + tableName);
}
}

@Test(groups = {DELTA_LAKE_DATABRICKS, DELTA_LAKE_OSS, DELTA_LAKE_EXCLUDE_73, PROFILE_SPECIFIC_TESTS})
@Flaky(issue = DATABRICKS_COMMUNICATION_FAILURE_ISSUE, match = DATABRICKS_COMMUNICATION_FAILURE_MATCH)
public void testCheckConstraintAcrossColumns()
Expand Down

0 comments on commit 9161ee7

Please sign in to comment.