[SPARK-40212] [SQL] SparkSQL castPartValue does not properly handle byte, short, or float#37659
Closed
BrennanStein wants to merge 2 commits intoapache:masterfrom
Closed
[SPARK-40212] [SQL] SparkSQL castPartValue does not properly handle byte, short, or float#37659BrennanStein wants to merge 2 commits intoapache:masterfrom
BrennanStein wants to merge 2 commits intoapache:masterfrom
Conversation
wangyum
reviewed
Aug 26, 2022
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala
Outdated
Show resolved
Hide resolved
wangyum
reviewed
Aug 26, 2022
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
|
Can one of the admins verify this patch? |
wangyum
approved these changes
Aug 28, 2022
Member
HyukjinKwon
approved these changes
Aug 29, 2022
Member
|
Merged to master and branch-3.3. |
HyukjinKwon
pushed a commit
that referenced
this pull request
Aug 29, 2022
…te, short, or float The `castPartValueToDesiredType` function now returns byte for ByteType and short for ShortType, rather than ints; also floats for FloatType rather than double. Previously, attempting to read back in a file partitioned on one of these column types would result in a ClassCastException at runtime (for Byte, `java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte`). I can't think this is anything but a bug, as returning the correct data type prevents the crash. Yes: it changes the observed behavior when reading in a byte/short/float-partitioned file. Added unit test. Without the `castPartValueToDesiredType` updates, the test fails with the stated exception. === I'll note that I'm not familiar enough with the spark repo to know if this will have ripple effects elsewhere, but tests pass on my fork and since the very similar https://github.com/apache/spark/pull/36344/files only needed to touch these two files I expect this change is self-contained as well. Closes #37659 from BrennanStein/spark40212. Authored-by: Brennan Stein <brennan.stein@ekata.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org> (cherry picked from commit 146f187) Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
The
castPartValueToDesiredTypefunction now returns byte for ByteType and short for ShortType, rather than ints; also floats for FloatType rather than double.Why are the changes needed?
Previously, attempting to read back in a file partitioned on one of these column types would result in a ClassCastException at runtime (for Byte,
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte). I can't think this is anything but a bug, as returning the correct data type prevents the crash.Does this PR introduce any user-facing change?
Yes: it changes the observed behavior when reading in a byte/short/float-partitioned file.
How was this patch tested?
Added unit test. Without the
castPartValueToDesiredTypeupdates, the test fails with the stated exception.===
I'll note that I'm not familiar enough with the spark repo to know if this will have ripple effects elsewhere, but tests pass on my fork and since the very similar https://github.com/apache/spark/pull/36344/files only needed to touch these two files I expect this change is self-contained as well.