[SPARK-47902][SQL]Making Compute Current Time* expressions foldable#46120
Closed
dbatomic wants to merge 5 commits intoapache:masterfrom
Closed
[SPARK-47902][SQL]Making Compute Current Time* expressions foldable#46120dbatomic wants to merge 5 commits intoapache:masterfrom
dbatomic wants to merge 5 commits intoapache:masterfrom
Conversation
cloud-fan
reviewed
Apr 19, 2024
| oneRowScalarSubquery) | ||
| } | ||
|
|
||
| test("Current time functions are constant folded") { |
Contributor
There was a problem hiding this comment.
I think what we need is an analyzer test to make sure we can use current_time in functions that require folding input, like rand. How about we move the test to ExpressionTypeCheckingSuite?
Contributor
Author
There was a problem hiding this comment.
Sure, please take a look.
cloud-fan
reviewed
Apr 19, 2024
|
|
||
| test("check that current time is foldable") { | ||
| val rnd = | ||
| Rand(Cast(UnixTimestamp(CurrentDate(), Literal("yyyy-MM-dd HH:mm:ss")), IntegerType)) |
Contributor
There was a problem hiding this comment.
int: we can simply do Month(CurrentDate()) to turn date into int.
cloud-fan
approved these changes
Apr 19, 2024
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?
This PR is a followed of this PR that made "compute current time" family of expressions
Unevaluable. Implicitly, allUnevaluableexpressions are also not foldable. Hence, we have a regression comparing to state prior to 44261 where "compute current time" expressions could have been used in places where constant folding is required.Proposed change is to keep these expression
Unevaluablein a sense thateval/codeGencan't be called but to allow folding. This is a special case given that these expressions are supposed to be replaced by QO with literals (that are foldable) so proposal is to create new interface for this family of expressions.Why are the changes needed?
Explained above.
Does this PR introduce any user-facing change?
Yes.
How was this patch tested?
Additional test is added that ensures that
CurrentDatecan be used in places that require folding.Was this patch authored or co-authored using generative AI tooling?
No.