-
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
Add support for varchar to timestamp coercion in hive tables #18014
Add support for varchar to timestamp coercion in hive tables #18014
Conversation
27cf204
to
9385cbc
Compare
9385cbc
to
6a087ce
Compare
ef81e4a
to
21edd63
Compare
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.
PR description says "varchar type to string"
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
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.
LGTM
plugin/trino-hive/src/main/java/io/trino/plugin/hive/coercions/TimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/coercions/TimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/coercions/TestTimestampCoercer.java
Outdated
Show resolved
Hide resolved
LocalDateTime dateTime = LOCAL_DATE_TIME.parse(value.toStringUtf8(), LocalDateTime::from); | ||
long epochSecond = dateTime.toEpochSecond(UTC); | ||
if (epochSecond < START_OF_MODERN_ERA_SECONDS) { | ||
throw new TrinoException(HIVE_INVALID_TIMESTAMP_COERCION, "Coercion on historical dates is not supported"); |
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 we throw exception here, we are not able to adjust date using GregorianCalendar and month -1
?
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.
Hive supports different way of coercing timestamp across various version (2 and 3) and various types (ORC/Parquet/RC) for some it uses java.sql.Timestamp
and other it uses a different way - so we are restricting them
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.
So we just cannot predict what is the way of storing such date in underlying datasource (is it for example shifted for -1 month or not), so we just deny such cases.
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 not storing but actually the way it coerces from String to Timestamp
- Static import of utf8Slice
21edd63
to
ed788a8
Compare
@krvikash AC |
plugin/trino-hive/src/main/java/io/trino/plugin/hive/coercions/TimestampCoercer.java
Show resolved
Hide resolved
plugin/trino-hive/src/main/java/io/trino/plugin/hive/coercions/TimestampCoercer.java
Show resolved
Hide resolved
@raunaqmorarka Thanks for the review. AC |
ed788a8
to
7d80d8d
Compare
7d80d8d
to
614ab46
Compare
Description
Allows coerce a varchar type to timestamp in hive tables.
Additional context and related issues
Depends on #18004
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.
(x) Release notes are required, with the following suggested text: