Skip to content
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

[fix](grouping sets) columns in grouping sets should not be in selectstmt‘s AggFunc #12313

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

zenoyang
Copy link
Member

@zenoyang zenoyang commented Sep 2, 2022

Proposed changes

Issue Number: close #12273
Fix grouping sets cause be core or return wrong results.

Problem summary

Describe your changes.

Checklist(Required)

  1. Does it affect the original behavior:
    • Yes
    • No
    • I don't know
  2. Has unit tests been added:
    • Yes
    • No
    • No Need
  3. Has document been added or modified:
    • Yes
    • No
    • No Need
  4. Does it need to update dependencies:
    • Yes
    • No
  5. Are there any changes that cannot be rolled back:
    • Yes (If Yes, please explain WHY)
    • No

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@github-actions github-actions bot added the area/planner Issues or PRs related to the query planner label Sep 2, 2022
@zenoyang zenoyang added kind/need-regression-test Need to add regression test for this case kind/fix Categorizes issue or PR as related to a bug. labels Sep 2, 2022
@zenoyang zenoyang removed kind/need-regression-test Need to add regression test for this case kind/test labels Sep 2, 2022
@spaces-X
Copy link
Contributor

spaces-X commented Sep 3, 2022

It seems that i got the exact same error a couple months ago, but the fix pr #10121 has not been merged into master yet.

I think the recurrence rate of the current bug is quite high, and I hope that a short-term fix can be merged to master rather than waiting for the new query optimizer's implement.

spaces-X
spaces-X previously approved these changes Sep 5, 2022
Copy link
Contributor

@spaces-X spaces-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Sep 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2022

PR approved by anyone and no changes requested.

@zenoyang zenoyang removed the approved Indicates a PR has been approved by one committer. label Sep 5, 2022
@zenoyang zenoyang force-pushed the 0901_fix_grouping_set branch 2 times, most recently from fb21030 to 29ed956 Compare September 6, 2022 07:09
spaces-X
spaces-X previously approved these changes Sep 7, 2022
Copy link
Contributor

@spaces-X spaces-X left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Sep 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

PR approved by at least one committer and no changes requested.

@spaces-X spaces-X changed the title [fix](grouping sets) grouping sets cause be core or return wrong results [fix](grouping sets) grouping sets's column should not be in select AggFunc cause be core or return wrong results Sep 7, 2022
@spaces-X spaces-X changed the title [fix](grouping sets) grouping sets's column should not be in select AggFunc cause be core or return wrong results [fix](grouping sets) grouping sets's column should not be in selectstmt‘s AggFunc Sep 7, 2022
@spaces-X spaces-X changed the title [fix](grouping sets) grouping sets's column should not be in selectstmt‘s AggFunc [fix](grouping sets) columns in grouping sets should not be in selectstmt‘s AggFunc Sep 7, 2022
if (item.getExpr() instanceof FunctionCallExpr && item.getExpr().fn instanceof AggregateFunction) {
aggFnExprList.clear();
getAggregateFnExpr(item.getExpr(), aggFnExprList);
if (!aggFnExprList.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more clear and simple:
for (Expr aggFnExpr : aggFnExprList) { for (Expr expr : groupByClause.getGroupingExprs()) { .... } }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private void getAggregateFnExpr(Expr expr, ArrayList<Expr> aggFnExprList) {
if (expr instanceof FunctionCallExpr && expr.fn instanceof AggregateFunction) {
aggFnExprList.add(expr);
} else if (expr.getChildren() != null && expr.getChildren().size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove else if (expr.getChildren() != null && expr.getChildren().size() > 0) call for (Expr child : expr.getChildren()) { getAggregateFnExpr(child, aggFnExprList); } directly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder, I have modified it, but I have kept else if (expr.getChildren() != null), otherwise it may cause NullPointerException.

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Sep 7, 2022
Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/planner Issues or PRs related to the query planner dev/merged-1.1.3-deprecated kind/fix Categorizes issue or PR as related to a bug. kind/test reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Grouping sets cause BE Core or return wrong results
6 participants