-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Introduce TrinoToClickHouseWriteChecker in ClickHouse #11148
Introduce TrinoToClickHouseWriteChecker in ClickHouse #11148
Conversation
a0c5748
to
44ed9f4
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.
Thanks. Left some initial comments.
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
.../test/java/io/trino/plugin/clickhouse/TestClickHouseLatestConnectorDateTimesTypeMapping.java
Outdated
Show resolved
Hide resolved
44ed9f4
to
32f4f1c
Compare
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
32f4f1c
to
8c2f64b
Compare
Updated, ping @ebyhr |
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 rebase on upstream to resolve conflicts.
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
...ino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestLatestClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
...ino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestLatestClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
...ino-clickhouse/src/test/java/io/trino/plugin/clickhouse/TestLatestClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/test/java/io/trino/plugin/clickhouse/BaseClickHouseTypeMapping.java
Outdated
Show resolved
Hide resolved
51316c0
to
f774c1a
Compare
Updated. |
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java
Outdated
Show resolved
Hide resolved
f774c1a
to
885f3ec
Compare
Minor fixs, PTAL @ebyhr |
AFAIK it was @ebyhr who discovered this behavior in the first place (see #10055 #11490). Then I found out that different versions of ClickHouse support different min-max values for date types (inspired by #10055, see #11116).
Sure, will do. |
4cb5f17
to
e55d54e
Compare
@hashhar PTAL updated PR(title, description, RN, addressed comments).
Once this PR is merged, I'll file follow-up PRs. |
Thanks, I'll take another look tomorrow. |
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. Please squash the fixup commits.
Different versions of ClickHouse may support different min/max values for the same data type, you can refer to the table below: | version | column type | min value | max value | |---------|-------------|---------------------|----------------------| | any | UInt8 | 0 | 255 | | any | UInt16 | 0 | 65535 | | any | UInt32 | 0 | 4294967295 | | any | UInt64 | 0 | 18446744073709551615 | | < 21.4 | Date | 1970-01-01 | 2106-02-07 | | < 21.4 | DateTime | 1970-01-01 00:00:00 | 2106-02-06 06:28:15 | | >= 21.4 | Date | 1970-01-01 | 2149-06-06 | | >= 21.4 | DateTime | 1970-01-01 00:00:00 | 2106-02-07 06:28:15 | And when the value written to ClickHouse is out of range, ClickHouse will store the incorrect result, so we introduced `TrinoToClickHouseWriteChecker` to check the range of the written value to prevent ClickHouse from storing the incorrect value. Introducing `TrinoToClickHouseWriteChecker` is also a preparation for supporting `DateTime[timezone]` and `DateTime64(precision, [timezone])`. The next several commits will use `TrinoToClickHouseWriteChecker` to verify the values written to ClickHouse.
This is a preparatory commit to use `TrinoToClickHouseWriteChecker` to validate Date.
This is a preparatory commit to use `TrinoToClickHouseWriteChecker` to validate DateTime.
5403be1
to
16968ba
Compare
done |
@tangjiangling Do we want a release note for this change? And is there a plan/need to write docs related to this as a follow-up? cc @hashhar |
RN entry is suggested in the PR description. It might be useful to document the supported range of values but it's not urgent since the values will vary and change according to ClickHouse version being used and a useful error message with relevant information is shown in those cases. |
Oops, somehow missed the release note in the PR description. And that sounds good to me. |
FYI, the date range was changed again in new version - see ClickHouse/clickhouse-java#1103. |
Thanks for the reminder, we already knew that (see #11148 (comment)) and I will continue this work. |
Description
Different versions of ClickHouse may support different min/max values
for the same data type, you can refer to the table below:
And when the value written to ClickHouse is out of range, ClickHouse
will store the incorrect result, so we introduced
TrinoToClickHouseWriteChecker
to check the range of the written valueto prevent ClickHouse from storing the incorrect value.
Introducing
TrinoToClickHouseWriteChecker
is also a preparation forsupporting
DateTime[(timezone)]
andDateTime64(precision, [timezone])
.Fixes part of #11116
Related #10537
Release notes
(x) Release notes entries required with the following suggested text: