-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-5483] ProjectAggregateMergeRule throws exception if literal is non-numeric #3038
[CALCITE-5483] ProjectAggregateMergeRule throws exception if literal is non-numeric #3038
Conversation
@@ -99,25 +100,27 @@ && kindCount(project.getProjects(), SqlKind.CASE) == 0) { | |||
&& operands.get(1).getKind() == SqlKind.CAST | |||
&& ((RexCall) operands.get(1)).operands.get(0).getKind() | |||
== SqlKind.INPUT_REF | |||
&& operands.get(2).getKind() == SqlKind.LITERAL) { | |||
&& operands.get(2).getKind() == SqlKind.LITERAL | |||
&& operands.get(2).getType().getFamily() == SqlTypeFamily.NUMERIC) { |
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.
Optionally, you could move this test (operands.get(2).getType().getFamily() == SqlTypeFamily.NUMERIC
) to just before the call to literal.getValueAs(BigDecimal.class)
- it might have better context.
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 was meant to remove this check originally since we can assume the operand is numeric when the aggregator is SUM
. Sorry that this was still in my git staging.
Kudos, SonarCloud Quality Gate passed! |
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.
LGTM
@birschick-bq Thanks for your review. I'll merge this after '1.33.0' is out if there is no more objections anymore. And I'll add @birschick-bq as the co-author since this PR is mostly based on his #3031. |
…is non-numeric Close apache#3038 Co-authored-by: Bruce Irschick <brucei@bitquilltech.com>
This PR is based on #3031 from @birschick-bq