-
Notifications
You must be signed in to change notification settings - Fork 239
[CALCITE-5094] Calcite JDBC Adapter and Avatica should support MySQL UNSIGNED types of TINYINT, SMALLINT, INT, BIGINT #275
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
Conversation
2677782 to
629a5ef
Compare
mihaibudiu
left 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.
The changes look fine, but it's hard to tell whether all code paths that may be relevant have been handled until we have some end-to-end tests.
Yes, I agree with you, end-to-end testing is very important. Currently, I have tested different unsigned types with |
|
I am wondering whether it will pay off to actually build a set of classes UnsignedInt, UnsignedShort, etc, which would encapsulate these abstractions in a clean way. I am not sure that this is the right place for them - BTW. But I think you will need them eventually in the runtime of Calcite to properly implement the semantics of unsigned arithmetic. |
|
I notice that Guava has some of these. |
|
@mihaibudiu Thank you for your remind, I will try to implement this feature using a class like Guava UnsignedInt. |
|
Hi @mihaibudiu, I spent some time looking at Guava. Currently, it only provides In addition, I found that MySQL provides another idea, we can handle them by mapping a wider range of Java types. For example, the Through this mapping conversion method, we do not need to add any classes, and the Calcite runtime can handle UNSIGNED types. What do you think of this approach? I will keep trying if you have any suggestions. |
ILuffZhe
left 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.
Overall looks good.
core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetThrowsSqlExceptionTest.java
Show resolved
Hide resolved
|
From my experience, in the long term it pays off to implement the right abstractions. |
Hi @mihaibudiu, thank you for sharing these valuable experiences. These are issues I had not considered before. Since I am still a novice, I will spend some time to understand type checking, expression simplification, etc., and then try to add new UnsignedInt, UnsignedLong and other types. |
c7cee40 to
a9dc6f8
Compare
|
Can we merge this PR? |
Hi @mihaibudiu, according to your review suggestion, we'd better introduce unsigned type to facilitate Calcite to do some boundary checking on types. This part of work is not included in the current PR. I suggest merging this PR first, and then I will introduce https://github.com/jOOQ/jOOU in the next PR to support unsigned type. What do you think? |
|
I don't know if Avatica needs to take a dependency on joou. |
Good suggestion, I will add tests in calcite. |
cdc32af to
ebaed66
Compare
|
There is now apache/calcite#4411; I guess the tests should use both PRs. |
Yes, I will test in calcite when #4411 is merged. |
|
I have resolved the issue in Jira, perhaps you should open a new one specifically mentioning Avatica. |
|
|
||
| @Override | ||
| public UShort getUShort() throws SQLException { | ||
| return UShort.valueOf(String.valueOf(getLong())); |
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.
this seems a bit convoluted
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.
This is because the UShort.valueOf method does not support long type parameters.
| Types.TINYINT, "TINYINT", ColumnMetaData.Rep.BYTE), true, true), | ||
| MetaImpl.columnMetaData("shortField", 2, ColumnMetaData.scalar( | ||
| Types.SMALLINT, "SMALLINT", ColumnMetaData.Rep.SHORT), true, true), | ||
| MetaImpl.columnMetaData("intField", 3, ColumnMetaData.scalar( |
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.
this we don't have, right?
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, while I was adding tests for unsigned types, I noticed that signed types were also lacking tests, so I added those tests.
|
Please rebase and squash the commits. |
0a7faf9 to
7ce7b5e
Compare
…UNSIGNED types of TINYINT, SMALLINT, INT, BIGINT
7ce7b5e to
274b117
Compare
For more details, refer jira: https://issues.apache.org/jira/browse/CALCITE-5094