[SPARK-40610][SQL] Support unwrap date type to string type#40294
Closed
wangyum wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-40610][SQL] Support unwrap date type to string type#40294wangyum wants to merge 1 commit intoapache:masterfrom
wangyum wants to merge 1 commit intoapache:masterfrom
Conversation
Member
Author
cloud-fan
reviewed
Mar 7, 2023
| case be @ BinaryComparison( | ||
| Cast(fromExp, _, timeZoneId, evalMode), date @ Literal(value, DateType)) | ||
| if fromExp.dataType == StringType && value != null => | ||
| be.withNewChildren(Seq(fromExp, Cast(date, StringType, timeZoneId, evalMode))) |
Contributor
There was a problem hiding this comment.
This is tricky, as we need to be very careful about the reverse of date string parsing. Can we reference the detail of date string parsing in Cast and prove it's safe to do this optimization?
There was a problem hiding this comment.
UnwrapCastInBinaryComparison class is only responsible for processing casts related to numeric types, and it is dangerous to cast date types. Can we add the related conversion of partition columns to the PruneHiveTablePartitions rule?
Member
Author
|
Close it, because this change may have potential data issue. Users can |
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?
This PR enhances
UnwrapCastInBinaryComparisonto support unwrapping date type to string type.Why are the changes needed?
Avoid always fetching all partitions because the partition filters cannot be pushed down to the Hive metastore. For example:
Before Spark 3.0. It pushes partition filters to Hive metastore:
After SPARK-27638. Because it can not convert partition filters to hive metastore filters, it will not push partition filters to Hive metastore. As a result, it always takes all the parititons:
After this PR. It unwraps date type to string type and then pushes partition filters to Hive metastore:
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Unit test.