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

planner: reset not null flag when Apply convert to Join #19567

Merged
merged 6 commits into from
Aug 31, 2020

Conversation

wshwsh12
Copy link
Contributor

@wshwsh12 wshwsh12 commented Aug 28, 2020

What problem does this PR solve?

Issue Number: close #19504

Problem Summary:

  1. Apply->Agg convert to Agg->LeftOuterJoin, but not reset not null flag.
  2. Eliminate Agg to Projection 1 -> Column, instand of ifnull(column, 0) -> Column.https://github.com/pingcap/tidb/blob/master/planner/core/rule_aggregation_elimination.go#L111

What is changed and how it works?

Proposal: xxx

What's Changed:

  1. Reset not null flag.
  2. Rebuild aggfuncs to use these columns.

How it Works:

Related changes

  • Need to cherry-pick to the release branch 4.0

Check List

Tests

  • Unit test
  • Integration test

Release note

  • Fix wrong result for aggregation count(col)

@wshwsh12 wshwsh12 requested review from a team as code owners August 28, 2020 06:11
@wshwsh12 wshwsh12 requested review from lzmhhh123 and removed request for a team August 28, 2020 06:11
Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 28, 2020
@XuHuaiyu
Copy link
Contributor

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Aug 31, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Aug 31, 2020
@wshwsh12
Copy link
Contributor Author

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 31, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@wshwsh12 merge failed.

@wshwsh12
Copy link
Contributor Author

/run-all-tests

@wshwsh12 wshwsh12 merged commit 27ea908 into pingcap:master Aug 31, 2020
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Aug 31, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #19628

ti-srebot added a commit that referenced this pull request Sep 1, 2020
)

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@XuHuaiyu
Copy link
Contributor

tidb> select (select count(c_int*c_int) from t2 where c_int = t1.c_int) c1, (select count(1) from t2 where c_int = t1.c_int) c2 from t1;
ERROR 1105 (HY000): interface conversion: expression.Expression is *expression.ScalarFunction, not *expression.Column

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Results of count(col) and count(1) may be different
4 participants