-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix Delta Lake insertion issue by setting UTC timezone for timestamp with timezone partition column #16878
Conversation
…with time zone type
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.
Please add both normal test and product test.
Sure, still working on this. |
4cc4d47
to
3456fc5
Compare
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/AbstractDeltaLakePageSink.java
Show resolved
Hide resolved
...c/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksInsertCompatibility.java
Show resolved
Hide resolved
…with timezone partition column
@ebyhr and @findinpath Welcome for any comments |
@ebyhr and @findinpath I guess this is close to getting merged :) |
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.
Please squash commits into one.
if (position.getErrorIndex() == -1 && timestamp.length() == position.getIndex()) { | ||
if (accessor.isSupported(NANO_OF_SECOND)) { |
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.
These conditions look hard to understand for me. Could you leave a code comment with the example?
|
||
public final class DeltaLakeWriteUtils | ||
{ | ||
private DeltaLakeWriteUtils() {} |
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.
What's the difference from HiveWriteUtils
? Please leave a code comment.
String tableName = "test_dl_partitioned_insert_timestampTZ" + randomNameSuffix(); | ||
onTrino().executeQuery("" + | ||
"CREATE TABLE delta.default." + tableName + | ||
" (c1 INT, c2 TIMESTAMP WITH TIME ZONE)" + |
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.
Please add a test for partitioned by nested type with timestamp with time zone.
onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (1, TIMESTAMP '2023-04-05 10:00:00.666+01:00')"); | ||
onTrino().executeQuery("INSERT INTO delta.default." + tableName + " VALUES (2, TIMESTAMP '2023-04-06 10:00:00+01:00')"); |
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.
nit: No need to split into two INSERT statements.
row( | ||
2, | ||
Timestamp.valueOf("2023-04-06 09:00:00"))); | ||
assertThat(onTrino().executeQuery("SELECT c1, CAST(c2 AS TIMESTAMP) FROM delta.default." + tableName + " ORDER BY c1 ASC")) |
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.
Remove redundant ORDER BY
@@ -130,6 +131,37 @@ public void testPartitionedInsertCompatibility() | |||
} | |||
} | |||
|
|||
@Test(groups = {DELTA_LAKE_DATABRICKS, DELTA_LAKE_OSS, PROFILE_SPECIFIC_TESTS}) | |||
public void testPartitionedInsertTimestampTZCompatibility() |
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.
public void testPartitionedInsertTimestampTZCompatibility() | |
public void testPartitionedInsertTimestampWithTimeZoneCompatibility() |
return partitionValues.build(); | ||
} | ||
|
||
public static Object getField(DateTimeZone localZone, Type type, Block block, int position) |
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.
All types in this method are required in Delta Lake connector?
else { | ||
int picosOfMilli = block.getInt(position, SIZE_OF_LONG); | ||
Instant instant = Instant.ofEpochMilli(millisUtc).plusNanos(picosOfMilli * 1000); | ||
return new TimestampTZ(instant.getEpochSecond(), instant.getNano(), UTC_KEY.getZoneId()); | ||
} |
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.
Is this condition used in Delta Lake connector?
@albericgenius Are you still working on this? |
Superseded by #18353 |
…with time zone type
Description
Fix #16822
Additional context and related issues
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: