-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22109][SQL] Resolves type conflicts between strings and timestamps in partition column #19331
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
Closed
Closed
[SPARK-22109][SQL] Resolves type conflicts between strings and timestamps in partition column #19331
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
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 such a quick fix!
but, don't we also need to update
upCastingOrder? It seems this happens to work becauseupcastingOrder.indexOf(TimestampType) = -1. But I think that doesn't compare the right way with NullType, so if you add this toParquetPartitionDiscoverySuite.test("parse partitions"), it fails:(I have to admit, I don't totally understand what the ramifications of that fail are -- the behavior in the resulting dataframe seems fine to me, but I figure there is probably some case this would mess up ...)
Uh oh!
There was an error while loading. Please reload this page.
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 see. Actually, I believe this PR fixed only the (corner) regression between 2.1.0 and 2.2.0 because, if I understood correctly, we started to support infer timestamp in partition column from 2.1.0, SPARK-17388, and this corner regression was introduced from 2.2.0 SPARK-18939 (not tested).
For the issue you described above, which I believe existed from 2.1.0 (not tested), I think that also should be applied to
DecimalType,DateTypeandTimestampTypewhich were started to be supported from SPARK-17388 and should strictly be related with this issue, SPARK-22109, but orthogonal.For perfectness, I guess we should port this logic:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
Lines 135 to 150 in 183d4cb
because the problem is,
TimestampType,DateTypeandDecimalTypecan't be upcasted to other types easily by comparing numeric precedence, but of course with few special handling because we are currently only inferring decimals whenscale <= 0(e.g., not 1.1) and castable to a decimal before trying a double:spark/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningUtils.scala
Lines 384 to 393 in 04975a6
This actually also could a problem of types between
DateTypeandTimestampTypewhich should be upcastable (from date to timestamp), which might end up withDateType.Let me take a closer look and probably make a fix soon.