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

user variable in GROUP BY might be wrongly pruned in logical optimization #27093

Closed
time-and-fate opened this issue Aug 11, 2021 · 5 comments
Closed
Assignees
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@time-and-fate
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int, b int);
insert into t value(1,1), (2,2), (3,3);
set @n = 1;
explain select @n:=@n+1 as e from t group by e;
select @n:=@n+1 as e from t group by e;

2. What did you expect to see? (Required)

+------+
| e    |
+------+
|    2 |
|    3 |
|    4 |
+------+

3. What did you see instead (Required)

+-----------------------------+---------+-----------+---------------+-------------------------------------------------------+
| id                          | estRows | task      | access object | operator info                                         |
+-----------------------------+---------+-----------+---------------+-------------------------------------------------------+
| Projection_4                | 1.00    | root      |               | setvar(n, plus(getvar(n), 1))->Column#4               |
| └─HashAgg_9                 | 1.00    | root      |               | group by:Column#8, funcs:firstrow(Column#8)->Column#7 |
|   └─TableReader_10          | 1.00    | root      |               | data:HashAgg_5                                        |
|     └─HashAgg_5             | 1.00    | cop[tikv] |               | group by:1,                                           |
|       └─TableFullScan_8     | 3.00    | cop[tikv] | table:t       | keep order:false, stats:pseudo                        |
+-----------------------------+---------+-----------+---------------+-------------------------------------------------------+
+---+
| e |
+---+
| 2 |
+---+

4. What is your TiDB version? (Required)

current master

This should be introduced by enabling push down agg below projection by default in #22090.
Before #22090, this can also be triggered by turning on tidb_opt_agg_push_down.

@time-and-fate time-and-fate added the type/bug The issue is confirmed as a bug. label Aug 11, 2021
@time-and-fate
Copy link
Member Author

/sig planner

@ti-chi-bot ti-chi-bot added the sig/planner SIG: Planner label Aug 11, 2021
@time-and-fate
Copy link
Member Author

/assign time-and-fate

@time-and-fate
Copy link
Member Author

The same reason as #27106.

@time-and-fate
Copy link
Member Author

Close this one since duplicated with #27106.

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants