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: fix agg push down rule mistake order by item inside agg function #50002

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/planner/core/rule_aggregation_push_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func (a *aggregationPushDownSolver) aggPushDown(p LogicalPlan, opt *logicalOptim
break
}
}
for j, item := range newAggOrderItems {
for j, item := range newAggOrderItems[i] {
if item == nil {
continue
}
Expand Down
15 changes: 15 additions & 0 deletions tests/integrationtest/r/expression/issues.result
Original file line number Diff line number Diff line change
Expand Up @@ -3177,3 +3177,18 @@ a b
update test.t set b = 0 where (a, b) in (('a', 1), (null, 0));
SHOW WARNINGS;
Level Code Message
drop table if exists test.t;
create table if not exists test.ast (i varchar(20));
create table if not exists test.acc (j varchar(20), k varchar(20), l varchar(20), m varchar(20));
explain format='brief' with t as(select i, (case when b.j = '20001' then b.l else b.k end) an from test.ast a inner join test.acc b on (a.i = b.m) and a.i = 'astp2019121731703151'), t1 as (select i, group_concat(an order by an separator '; ') an from t group by i) select * from t1;
id estRows task access object operator info
Projection 8.00 root test.ast.i, Column#32
└─HashAgg 8.00 root group by:Column#37, funcs:group_concat(Column#34 order by Column#35 separator "; ")->Column#32, funcs:firstrow(Column#36)->test.ast.i
└─Projection 100.00 root case(eq(test.acc.j, 20001), test.acc.l, test.acc.k)->Column#34, case(eq(test.acc.j, 20001), test.acc.l, test.acc.k)->Column#35, test.ast.i->Column#36, test.ast.i->Column#37
└─HashJoin 100.00 root CARTESIAN inner join
├─TableReader(Build) 10.00 root data:Selection
│ └─Selection 10.00 cop[tikv] eq(test.ast.i, "astp2019121731703151")
│ └─TableFullScan 10000.00 cop[tikv] table:a keep order:false, stats:pseudo
└─TableReader(Probe) 10.00 root data:Selection
└─Selection 10.00 cop[tikv] eq("astp2019121731703151", test.acc.m)
└─TableFullScan 10000.00 cop[tikv] table:b keep order:false, stats:pseudo
8 changes: 7 additions & 1 deletion tests/integrationtest/t/expression/issues.test
Original file line number Diff line number Diff line change
Expand Up @@ -2154,4 +2154,10 @@ create table test.t (a varchar(10), b tinyint(1));
insert into test.t values ("abc", 1);
select * from test.t where (a, b) in (('a', 1), (null, 0));
update test.t set b = 0 where (a, b) in (('a', 1), (null, 0));
SHOW WARNINGS;
SHOW WARNINGS;

# TestIssue49986
drop table if exists test.t;
create table if not exists test.ast (i varchar(20));
create table if not exists test.acc (j varchar(20), k varchar(20), l varchar(20), m varchar(20));
explain format='brief' with t as(select i, (case when b.j = '20001' then b.l else b.k end) an from test.ast a inner join test.acc b on (a.i = b.m) and a.i = 'astp2019121731703151'), t1 as (select i, group_concat(an order by an separator '; ') an from t group by i) select * from t1;