-
Notifications
You must be signed in to change notification settings - Fork 513
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
Prepare for JDBC 4.2 #406 #418
Conversation
@alex-krash did you have time to take a look at this PR? I am happy to discuss any issues. Have a good day! |
@enqueue , sorry for delay. Will take a look now. |
pom.xml
Outdated
@@ -4,7 +4,7 @@ | |||
|
|||
<groupId>ru.yandex.clickhouse</groupId> | |||
<artifactId>clickhouse-jdbc</artifactId> | |||
<version>0.2.4</version> | |||
<version>0.2.4-enqueue</version> |
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, avoid changes like this, in order not to pollute master branch.
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.
Sorry, this was a mistake
case UInt32: | ||
case UInt64: | ||
try { | ||
long l = Long.parseLong(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.
- We may have UInt64 overflow here
- Why all these things in class
ClickHouseDateValueParser
? That's really confusing.
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, I had not thought of this. New implementation truncates to milliseconds.
- The code should not be confusing, let's see if we can improve it.
ClickHouseDateValueParser
provides basic functionality for all date/time parsing. This makes the individual implementations much easier to read. We could move the "utility" methods (lines 146 ff.) into the actual implementations. Do you think that this would help overall simplicity?
LocalTime parseDate(String value, ClickHouseColumnInfo columnInfo, | ||
TimeZone timeZone) | ||
{ | ||
return LocalTime.MIDNIGHT; |
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.
Are you sure, that it is ok?
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 the most straightforward response in my opinion. The ClickHouse column is of type Date, e.g. "2020-03-07". If we adjusted midnight server time zone into JVM time zone, we would perhaps cause more confusion.
Hi @alex-krash , thank you for taking the time to review this very large PR ❤️ Moving to Java 8 is an important step that will also help to keep libraries up to date. 0.2 releases containing the state of development as of now will still available for die-hard Java 6 users. |
Any updates on when this PR might get merged and released? |
For Date and DateTime fields, the JDBC driver has enough time zone related information available, so these methods would only be relevant for String or other typed fields. There might be valid use cases, but for now we think that adding such an option would make things even more complicated. | ||
|
||
Requested Type | Number | Date | DateTime | Other | ||
---------------| ---------------------------------- |
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.
missing |
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.
Thank you @pan3793 ! After almost a year, someone stumbles upon wrongly formatted tables in the documentation... 😃 I added a couple of pipes, and the table looks better now in the preview.
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.
There are so many tricks about timezone, especially in legacy Java Date
API. I also encountered some issues when migrated to java.time
API from legacy Date
API in another ClickHouse JDBC driver implement in native protocol. And would you mind me pick up some code and doc from this PR?
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, life would be boring without time zones and leap seconds. Feel free to use the code in this PR, but please let me know when you find any error, so I can fix it. Have a good weekend!
Hello |
Hi @alongls this PR is for improvements in the official ClickHouse JDBC driver. Please follow ClickHouse/metabase-clickhouse-driver#58 for an updated Metabase driver. We use this branch for the driver, so it would be nice to see the PR reviewed and merged and use the official distribution, but perhaps it's too much work for maintainer due to size or other reasons. |
Thanks @enqueue. This is really a large PR. I quickly walked through the changes today, but I still need a few more days to play with the code(and maybe benchmark too). |
🟢 verify using JDK [13] and ClickHouse [21.2]: success |
🔴 verify using JDK [15.0.2] and ClickHouse [21]: failure |
🟢 benchmark using JDK [8] and ClickHouse [latest]: success Expand to see details...
|
@enqueue, the build break is caused by below code snippets in Long offset = Long.valueOf(
TimeUnit.MILLISECONDS.toHours(
connectionServerTz.getTimeZone().getOffset(currentTime)) - 1); I'm not sure why we need to deduct one here - it works if I remove that part. Could you take a look? |
I'll take the risk to merge this large PR in order to unblock future development. I'll create separate PR to fix above issues as well as existing ones in |
@enqueue, I'm not sure if mvn -Duser.timezone=Etc/UTC -DclickhouseTimezone=Europe/Moscow clean verify Anyway, I'll restructure directories tomorrow and start to add more features in the next following days. If you have time, you may want to review the changes I made in PR #580 and the 3 test cases I temporarily disabled(search |
Enhance parsing and retrieving of date time values, especially using
java.time
objects (issue #406 )PreparedStatement
java.time
ObjectsFloat32
is actually a SQL type REAL according to my understanding. I do not have access to any of the SQL standards, but see for example PostgreSQL manual, MS SQL Server manual, Oracle DatatypesByteFragmentUtils
I am sorry this PR is so large. I tried to create individual commits at least for some specific parts. If you have a good suggestion on how to split the PR, please let me know.