-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-14536] [SQL] fix to handle null value in array type column for postgres. #15192
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-14536] [SQL] fix to handle null value in array type column for postgres. #15192
Conversation
|
Test build #65751 has finished for PR 15192 at commit
|
|
@srowen SPARK-14536 is not a duplicate, this PR will address the issue. |
|
@sureshthalamati Any plans to get the conflicts fixed here and get things merged? |
|
The original support by array type is done in #9662. Could you resolve the conflicts and reproduce the error in the latest code base? |
|
sure. I will resolve the conflicts today. |
|
Thanks! |
9eb40db to
eeba2b1
Compare
|
Test build #71648 has finished for PR 15192 at commit
|
|
@gatorsmile Verified on the master , problem still exist. Resolved the conflicts, when u get a chance can you please review. Error stack without the fix |
| rs.getArray(pos + 1).getArray, | ||
| array => new GenericArrayData(elementConversion.apply(array))) | ||
| val array = nullSafeConvert[java.sql.Array]( | ||
| rs.getArray(pos + 1), |
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.
Nit: input = rs.getArray(pos + 1),
| assert(rows(0).getFloat(15) == 1.01f) | ||
| assert(rows(0).getShort(16) == 1) | ||
|
|
||
| // Test reading null values. |
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 reading null values using the second row.
| assert(rows.length == 1) | ||
| val rows = df.collect().sortBy(_.toString()) | ||
| assert(rows.length == 2) | ||
| val types = rows(0).toSeq.map(x => x.getClass) |
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.
Add a comment above this line to indicate the following statements are testing the first row.
|
Will also run the docker integration tests in my local computer. Post the results later. Thanks! |
|
LGTM pending test. The docker integration test cases pass in my local computer. However, I saw a not-related test case failure: Submitted a JIRA: https://issues.apache.org/jira/browse/SPARK-19318 @sureshthalamati could you take a look at it and fix it? Thanks! |
|
Test build #71746 has finished for PR 15192 at commit
|
|
Thanks! Merging to master. |
|
Thank you, @gatorsmile |
|
Thanks guys, this will be super, super helpful to us! |
…postgres. ## What changes were proposed in this pull request? JDBC read is failing with NPE due to missing null value check for array data type if the source table has null values in the array type column. For null values Resultset.getArray() returns null. This PR adds null safe check to the Resultset.getArray() value before invoking method on the Array object. ## How was this patch tested? Updated the PostgresIntegration test suite to test null values. Ran docker integration tests on my laptop. Author: sureshthalamati <[email protected]> Closes apache#15192 from sureshthalamati/jdbc_array_null_fix-SPARK-14536.
…postgres. ## What changes were proposed in this pull request? JDBC read is failing with NPE due to missing null value check for array data type if the source table has null values in the array type column. For null values Resultset.getArray() returns null. This PR adds null safe check to the Resultset.getArray() value before invoking method on the Array object. ## How was this patch tested? Updated the PostgresIntegration test suite to test null values. Ran docker integration tests on my laptop. Author: sureshthalamati <[email protected]> Closes apache#15192 from sureshthalamati/jdbc_array_null_fix-SPARK-14536.
|
Hi @gatorsmile , on the dev@ list someone asked if this was something we were considering backporting into the 2.1 branch (for the 2.1.1 release). It looks like it might be a reasonable candidate for this so I figured since you were the one who committed it you might want to take a look and decide? |
|
@holdenk Sure, we can backport it to Spark 2.1. @sureshthalamati Could you please back port it to Spark 2.1? |
|
sure. Thanks |
|
Created PR to back port this fix to 2.1: #17460 |
What changes were proposed in this pull request?
JDBC read is failing with NPE due to missing null value check for array data type if the source table has null values in the array type column. For null values Resultset.getArray() returns null.
This PR adds null safe check to the Resultset.getArray() value before invoking method on the Array object.
How was this patch tested?
Updated the PostgresIntegration test suite to test null values. Ran docker integration tests on my laptop.