Skip to content

Commit

Permalink
planner: fix wrong empty projection (#53235) (#53240)
Browse files Browse the repository at this point in the history
close #49109
  • Loading branch information
ti-chi-bot authored May 28, 2024
1 parent 5ddedc2 commit ff05c7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/planner/core/rule_column_pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column, opt
if err != nil {
return nil, err
}
addConstOneForEmptyProjection(p.children[0])
return p, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ id value
3 0
4 4
5 5
drop table if exists t0, t1;
CREATE TABLE t0(c0 NUMERIC);
CREATE TABLE t1(c0 NUMERIC);
INSERT INTO t0 VALUES (0), (NULL), (1), (2);
INSERT INTO t1(c0) VALUES (NULL), (3), (4), (5);
drop view if exists v0;
CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t0;
SELECT t0.c0 FROM v0, t0 LEFT JOIN t1 ON t0.c0 WHERE ((INET_ATON('5V')) IS NULL);
c0
CREATE TABLE `t_o9_7_f` (
`c_ob5k0` int(11) NOT NULL,
`c_r5axbk` tinyint(4) DEFAULT NULL,
Expand Down
10 changes: 10 additions & 0 deletions tests/integrationtest/t/planner/core/issuetest/planner_issue.test
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ where test2.id in
);
select * from test2;

# https://github.com/pingcap/tidb/issues/49109
drop table if exists t0, t1;
CREATE TABLE t0(c0 NUMERIC);
CREATE TABLE t1(c0 NUMERIC);
INSERT INTO t0 VALUES (0), (NULL), (1), (2);
INSERT INTO t1(c0) VALUES (NULL), (3), (4), (5);
drop view if exists v0;
CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t0;

SELECT t0.c0 FROM v0, t0 LEFT JOIN t1 ON t0.c0 WHERE ((INET_ATON('5V')) IS NULL);
# https://github.com/pingcap/tidb/issues/52687
CREATE TABLE `t_o9_7_f` (
`c_ob5k0` int(11) NOT NULL,
Expand Down

0 comments on commit ff05c7a

Please sign in to comment.