-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Validate out of range DateTime value in clickhouse connector #26703
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
Validate out of range DateTime value in clickhouse connector #26703
Conversation
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
c75b5a9
to
4e46e02
Compare
Thanks @chenjian2664, Addressed your comments. |
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Show resolved
Hide resolved
return (resultSet, columnIndex) -> { | ||
ZonedDateTime zonedDateTime = resultSet.getObject(columnIndex, ZonedDateTime.class); | ||
return packDateTimeWithZone(zonedDateTime.toInstant().toEpochMilli(), zonedDateTime.getZone().getId()); | ||
}; |
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 think we should validate the reading as well
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.
When an out-of-range value is inserted into a ClickHouse table, ClickHouse stores it incorrectly by mapping it to a value within the supported range.
Example:
1912-01-01 00:00:00
→ stored as 1970-01-01 00:00:00
3102-01-01 00:00:00
→ stored as 2027-10-17 11:03:28
In Trino, the value that gets read appears to be within the supported range, making it impossible to tell whether 1970-01-01 00:00:00
was originally 1912-01-01 00:00:00
or actually 1970-01-01 00:00: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.
3102-01-01 00:00:00
→ stored as2027-10-17 11:03:28
Just curious: If the given date above MAX it's stored not as MAX (2106-02-07 06:28:15) but as 2027-10-17 11:03:28 ?
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.
Yes, I have checked with some different values as well and it is inserting different values for those cases.
4e46e02
to
c04a715
Compare
Thanks @anusudarsan @chenjian2664, AC. |
c04a715
to
3c5d35e
Compare
3c5d35e
to
efc1e3a
Compare
(rebased with master) |
import static io.trino.plugin.clickhouse.TestingClickHouseServer.ALTINITY_DEFAULT_IMAGE; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
public class TestAltinityClickHouseTypeMapping |
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.
Test classes should be defined as package-private and final.
Test methods should be defined as package-private.
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.
Since testUnsupportedPoint
is declared public in the base class, it cannot be made package-private in this subclass.
Need refactoring of Base class. I think that can be a follow up.
efc1e3a
to
c41a9f1
Compare
return (resultSet, columnIndex) -> { | ||
ZonedDateTime zonedDateTime = resultSet.getObject(columnIndex, ZonedDateTime.class); | ||
return packDateTimeWithZone(zonedDateTime.toInstant().toEpochMilli(), zonedDateTime.getZone().getId()); | ||
}; |
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.
3102-01-01 00:00:00
→ stored as2027-10-17 11:03:28
Just curious: If the given date above MAX it's stored not as MAX (2106-02-07 06:28:15) but as 2027-10-17 11:03:28 ?
Description
Validate out of range DateTime value in clickhouse connector
( ) This is not user-visible or is 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: