-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-10655][SQL] Adding additional data type mappings to jdbc DB2dialect. #9162
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
[SPARK-10655][SQL] Adding additional data type mappings to jdbc DB2dialect. #9162
Conversation
|
Jenkins, test this please. |
|
Test build #1930 has finished for PR 9162 at commit
|
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.
isn't this mapping it to normal decimal with precision 31?
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.e. precision lost here?
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.
Using this mapping DB2 will throw error if the precision of the value being written is > 31 during insert execution. But if the value scale is higher than 2 , value will rounded to scale of 2.
Other alternative was to let it fail with error when create table is executed (current behavior). I was not sure how common the decimal type system default (38, 18) is used to create the data frame. I thought it is better to map to DB2 max precision, instead of failing with error ,considering there is no way to write decimals of precision > 31 to DB2.
If you think it is better to fail on create , instead of surprises during execution. I will update the patch.
I am also working on creating pull request (SPARK-10849) to allow users to specify the target database column type. This will allow user to specify the decimal precision, and scale of their choice in these kind of scenarios.
|
Thank you for reviewing patch , Reynold. Please let me know if it needs any more changes. |
|
I think these are fine defaults. The work on SPARK-10849 gives fine-grained control to power users. LGTM. Thanks. |
|
@rxin Wondering if I need any additional work on this patch ? Thanks. |
|
Hey @sureshthalamati, take a look at #9503, which we just merged to re-enable the Docker JDBC integration tests; you should be able to build on that patch to write integration tests that run against a real DB2 instance that's running in Docker. |
|
Thank you for the information , Josh. Luciano seems to working on creating PR for DB2 docker test setup. I will check with him , and incorporate the type mapping tests into the docker test case. |
ec8e546 to
729fb85
Compare
|
I have a wip pr #9893, and an open question that I think @JoshRosen could help about the JDBC drivers for the other docker tests. Anyway, these two PRs are independent of each other, no ? |
27eeba0 to
5d022be
Compare
|
Updated the PR with the DB2 docker test case for the DB2 specific type mappings added in this PR. TIME STAMP WITH TIME ZONE is DB2Z specific , I could not add the docker test case for this data type. Can you please review the updated PR. |
|
ping @JoshRosen @rxin This issue was blocked due to docker relates issues for a while. If you can review the updated PR , that will be great. |
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.
Is there a duplication of BooleanType line here ? probably copy + paste issue.
|
Other then the minor comment around BooleanType, it LGTM. |
|
Thanks, Luciano. Addressed your comment. |
|
@JoshRosen @rxin Any suggestions to improve this fix to get it merged ? |
|
Jenkins retest this please |
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.
How about DECFLOAT(16) and DECFLOAT(34)?
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 for reviewing @gatorsmile . Added test cases for those two variations of the DECFLOAT types.
|
Test build #65932 has finished for PR 9162 at commit
|
|
@sureshthalamati Could you please retest it using DB2? |
|
retest this please |
|
Test build #78198 has finished for PR 9162 at commit
|
|
sure @gatorsmile . Thanks. |
f85c3d9 to
8b8bc9a
Compare
|
@gatorsmile I rebased and ran the DB2 docker test on my machine, it ran fine. |
|
Test build #78337 has finished for PR 9162 at commit
|
|
The scope of this PR is just to the DB2 dialect. The risk is pretty small even if the fix might not cover all the scenarios. Thanks! @sureshthalamati LGTM |
|
Thanks! Merging to master. |
|
Thank you @gatorsmile |
…alect. This patch adds DB2 specific data type mappings for decfloat, real, xml , and timestamp with time zone (DB2Z specific type) types on read and for byte, short data types on write to the to jdbc data source DB2 dialect. Default mapping does not work for these types when reading/writing from DB2 database. Added docker test, and a JDBC unit test case. Author: sureshthalamati <[email protected]> Closes apache#9162 from sureshthalamati/db2dialect_enhancements-spark-10655.
This patch adds DB2 specific data type mappings for decfloat, real, xml , and timestamp with time zone (DB2Z specific type) types on read and for byte, short data types on write to the to jdbc data source DB2 dialect. Default mapping does not work for these types when reading/writing from DB2 database.
Added docker test, and a JDBC unit test case.