-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Enhancement] support constant folding in translating scalarOperator phase (backport #50734) #50848
Conversation
Cherry-pick of 01f048a has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr |
Signed-off-by: packy92 <[email protected]>
Signed-off-by: packy92 <[email protected]>
Signed-off-by: packy92 <[email protected]>
3eefdad
to
85157e1
Compare
Signed-off-by: packy92 <[email protected]>
Signed-off-by: packy92 <[email protected]>
Quality Gate passedIssues Measures |
Why I'm doing:
Failed to execute query like
Because of
What I'm doing:
After #49724, we will replace columnRef to constant if it's possible, but sometimes the translator may directly invoke visit() method instead of visitSlot() method.
So return constant if it's possible in visit() method.
Actually, this pr still can't resolve the constant folding totally. The below method can still return a columnRef even when it can be replaced by a constant.
SQL like
didn't replace the
a
to 1.Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
This is an automatic backport of pull request #50734 done by [Mergify](https://mergify.com). ## Why I'm doing: Failed to execute query like ``` with cc as (select 1 as a) select percentile_approx(1, cc.a) from cc; ``` Because of ``` if (!functionCallExpr.getChild(1).getType().isNumericType() || !functionCallExpr.getChild(1).isConstant()) { throw new SemanticException( "percentile_approx requires the second parameter's type is numeric constant type"); } ```
What I'm doing:
After #49724, we will replace columnRef to constant if it's possible, but sometimes the translator may directly invoke visit() method instead of visitSlot() method.
So return constant if it's possible in visit() method.
Actually, this pr still can't resolve the constant folding totally. The below method can still return a columnRef even when it can be replaced by a constant.
SQL like
didn't replace the
a
to 1.Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist: