[SPARK-38558][SQL] Remove unnecessary casts between IntegerType and IntDecimal#35863
Closed
cashmand wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-38558][SQL] Remove unnecessary casts between IntegerType and IntDecimal#35863cashmand wants to merge 1 commit intoapache:masterfrom
cashmand wants to merge 1 commit intoapache:masterfrom
Conversation
Contributor
|
@cashmand should we create a jira ticket and use the ticket id as pr title? may like |
Contributor
Author
|
Thanks @weixiuli, I created https://issues.apache.org/jira/browse/SPARK-38558. I couldn't figure out how to assign it to myself. I'm not sure if I don't have permission, or if I just missed something in the UI. |
HyukjinKwon
reviewed
Mar 16, 2022
| zero, | ||
| zero, | ||
| (n.cast(DecimalType.IntDecimal) / buckets.cast(DecimalType.IntDecimal)).cast(IntegerType), | ||
| (n div buckets).cast(IntegerType), |
Contributor
|
thanks, merging to master! |
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?
In
NTile, the number of rows per bucket is computed asn / buckets, wherenis the partition size, andbucketsis the argument toNTile(number of buckets). The code currently casts the arguments to IntDecimal, then casts the result back to IntegerType. This is unnecessary, since it is equivalent to just doing integer division, i.e.n div buckets. This PR makes that simplifying change.Why are the changes needed?
Simplifies the code, and avoids a couple of casts at run-time.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Relying on existing tests (specifically, org.apache.spark.sql.hive.execution.WindowQuerySuite).