Skip to content

Commit

Permalink
Fix Databricks 13.3 timestamp compatibility test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjo2144 authored and abusk committed Jan 22, 2024
1 parent 7906749 commit 2d06e65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static io.trino.tests.product.TestGroups.DELTA_LAKE_OSS;
import static io.trino.tests.product.TestGroups.PROFILE_SPECIFIC_TESTS;
import static io.trino.tests.product.deltalake.util.DatabricksVersion.DATABRICKS_104_RUNTIME_VERSION;
import static io.trino.tests.product.deltalake.util.DatabricksVersion.DATABRICKS_133_RUNTIME_VERSION;
import static io.trino.tests.product.deltalake.util.DeltaLakeTestUtils.DATABRICKS_COMMUNICATION_FAILURE_ISSUE;
import static io.trino.tests.product.deltalake.util.DeltaLakeTestUtils.DATABRICKS_COMMUNICATION_FAILURE_MATCH;
import static io.trino.tests.product.deltalake.util.DeltaLakeTestUtils.dropDeltaTableWithRetry;
Expand Down Expand Up @@ -159,9 +160,11 @@ public void testTimestampInsertCompatibility()
"(3, TIMESTAMP '2023-03-04 01:02:03.999')," +
"(4, TIMESTAMP '9999-12-31 23:59:59.999')");

// Databricks returns incorrect results before version 13.3
Optional<String> expected = databricksRuntimeVersion.map(version -> version.isAtLeast(DATABRICKS_133_RUNTIME_VERSION) ? "0001-01-01 00:00:00.000" : "0001-01-03 00:00:00.000");
assertThat(onDelta().executeQuery("SELECT id, date_format(ts, \"yyyy-MM-dd HH:mm:ss.SSS\") FROM default." + tableName))
.containsOnly(
row(1, databricksRuntimeVersion.isPresent() ? "0001-01-03 00:00:00.000" : "0001-01-01 00:00:00.000"), // Databricks returns incorrect results
row(1, expected.orElse("0001-01-01 00:00:00.000")),
row(2, "2023-01-02 01:02:03.999"),
row(3, "2023-03-04 01:02:03.999"),
row(4, "9999-12-31 23:59:59.999"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public record DatabricksVersion(int majorVersion, int minorVersion)
implements Comparable<DatabricksVersion>
{
public static final DatabricksVersion DATABRICKS_133_RUNTIME_VERSION = new DatabricksVersion(13, 3);
public static final DatabricksVersion DATABRICKS_122_RUNTIME_VERSION = new DatabricksVersion(12, 2);
public static final DatabricksVersion DATABRICKS_113_RUNTIME_VERSION = new DatabricksVersion(11, 3);
public static final DatabricksVersion DATABRICKS_104_RUNTIME_VERSION = new DatabricksVersion(10, 4);
Expand Down

0 comments on commit 2d06e65

Please sign in to comment.