-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[CALCITE-7242] Implement a rule to eliminate LITERAL_AGG so that other databases can handle it #4598
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
base: main
Are you sure you want to change the base?
Conversation
aefb4ad to
f7f2396
Compare
|
For example: select e.deptno, e.deptno < some (select deptno from emp where emp.ename = e.ename) as v from emp as e; |
8c4ff2c to
3562768
Compare
Can this log be converted into a test case? Typically, a rule should have one or more test cases in RelOptRulesTest.java for verification. To go a step further, a corresponding end-to-end test can be added in planner.iq to validate the correctness of the result. |
| final List<Integer> literalAggIndices = new ArrayList<>(); | ||
| for (int i = 0; i < aggCalls.size(); i++) { | ||
| final AggregateCall ac = aggCalls.get(i); | ||
| if (ac.getAggregation().getName().equals("LITERAL_AGG")) { |
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.
Would it be better to use ac.getAggregation().getKind() == SqlKind.LITERAL_AGG?
| import java.util.Map; | ||
|
|
||
| /** | ||
| * AggregateExtractLiteralAggRule gets rid of the LITERAL_AGG into most databases can handle. |
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.
Javadoc should typically describe what this rule does, specifically the transformation from which type of SQL to which other type of SQL, or from which type of Plan to which other type of Plan.
| } | ||
|
|
||
| @Override public void onMatch(RelOptRuleCall call) { | ||
| final LogicalAggregate aggregate = call.rel(0); |
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.
Is better to use Aggregate?
| } | ||
|
|
||
| // Create new Aggregate preserving groupSet/groupSets/hints. | ||
| final LogicalAggregate newAggregate = |
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 noticed that the operators in this rule are all created using the create method(Aggregate and Project). Could they be changed to use RelBuilder?
3562768 to
eca3593
Compare
| } else { | ||
| // Non-literal aggregate: compute its new output index in newAggregate. | ||
| final Integer newAggIndex = oldAggIndexToNewAggIndex.get(origAggIndex); | ||
| if (newAggIndex != null) { |
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.
assert newAggIndex != null ?Could the index here be null?
core/src/main/java/org/apache/calcite/rel/rules/AggregateExtractLiteralAggRule.java
Show resolved
Hide resolved
| public static final AggregateGroupingSetsToUnionRule AGGREGATE_GROUPING_SETS_TO_UNION = | ||
| AggregateGroupingSetsToUnionRule.Config.DEFAULT.toRule(); | ||
|
|
||
| /** Rule that gets rid of the LITERAL_AGG into most databases can handle. */ |
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 think a brief description of how the plan is transformed from one form to another is needed here, rather than describing where the rule will be used.
| /** Test case of | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-7242">[CALCITE-7242] | ||
| * Implement a rule to eliminate LITERAL_AGG so that other databases can handle it</a>. */ | ||
| @Test void testAggregateExtractLiteralAggRule1() { |
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.
If a rule requires multiple test cases, it's best to avoid naming them with a simple incrementing number suffix.. This makes it difficult to quickly understand the purpose of each test. For example, this name could be changed to something like testAggregateExtractLiteralAggRuleSomeLessThan.
|
CI failed, message is: |
core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
Outdated
Show resolved
Hide resolved
28328ce to
d2f7f9c
Compare
|
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions. |
|
What is the status of this PR? |
@mihaibudiu |
…r databases can handle it
25f57be to
33c290c
Compare
33c290c to
3e734d3
Compare
|



CALCITE-7242