-
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
Respect timestamp coercion when coercing complex column #17900
Respect timestamp coercion when coercing complex column #17900
Conversation
Use == for enum comparison
Get type directly from HiveColumnHandle instead of generating them from HiveType.
93da480
to
0631344
Compare
0631344
to
7cc5d79
Compare
7cc5d79
to
fd5118e
Compare
""" | ||
INSERT INTO %s | ||
SELECT | ||
(CAST(ROW (timestamp_value, -1) AS ROW(keep TIMESTAMP(9), si2i SMALLINT))), |
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 is the point of si2i
field?
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 is a non TIMESTAMP column which we are coercing so as to reproduce this issue
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.
Let's add a comment.
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.
But does the comment help here - in the next set of PRs we would be adding additional column like timestamp
which will be coerced.
plugin/trino-hive/src/main/java/io/trino/plugin/hive/HivePageSourceProvider.java
Show resolved
Hide resolved
@@ -108,6 +129,21 @@ private static HiveTableDefinition.HiveTableDefinitionBuilder tableDefinitionBui | |||
"STORED AS " + fileFormat); | |||
} | |||
|
|||
private static HiveTableDefinition.HiveTableDefinitionBuilder tableDefinitionForTimestampCoercionBuilder(String fileFormat, Optional<String> recommendTableName, Optional<String> rowFormat) |
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.
maybe recommendTableName
-> tableNamePrefix
?
" timestamp_map_to_map MAP<SMALLINT, STRUCT<keep: TIMESTAMP, si2i: SMALLINT>>" + | ||
") " + | ||
"PARTITIONED BY (id BIGINT) " + | ||
rowFormat.map(s -> format("ROW FORMAT %s ", s)).orElse("") + |
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: "ROW FORMAT " + s
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.
I wanted to have a unified representation across this class.
onHive().executeQuery(format("ALTER TABLE %s CHANGE COLUMN timestamp_row_to_row timestamp_row_to_row struct<keep:timestamp, si2i:int>", tableName)); | ||
onHive().executeQuery(format("ALTER TABLE %s CHANGE COLUMN timestamp_list_to_list timestamp_list_to_list array<struct<keep:timestamp, si2i:int>>", tableName)); | ||
onHive().executeQuery(format("ALTER TABLE %s CHANGE COLUMN timestamp_map_to_map timestamp_map_to_map map<int,struct<keep:timestamp, si2i:int>>", tableName)); |
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: uppercase data types?
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.
I was thinking on handling it as a follow-up once the changes related to coercion are implemented. WDYT ?
Previously MILLISECONDS precision was leaked when corecion applied on complex column even if coercion was not applied on timestamp column.
fd5118e
to
a538773
Compare
@krvikash AC |
Description
Previously MILLISECONDS precision was leaked when corecion applied on complex column even if coercion was not applied on timestamp column.
Additional context and related issues
Release notes
( ) This is not user-visible or docs only and no release notes are required.
(x) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: