Skip to content

Commit

Permalink
planner: fix wrong empty projection (#53235) (#53241)
Browse files Browse the repository at this point in the history
close #49109
  • Loading branch information
ti-chi-bot committed May 14, 2024
1 parent 3292ed1 commit 7df0ce3
Show file tree
Hide file tree
Showing 3 changed files with 21 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 @@ -520,3 +520,12 @@ t_q1 as ref_14
where (ref_14.c_z like 'o%fiah')))
where (t_kg74.c_obnq8s7_s2 = case when (t_kg74.c_a1tv2 is NULL) then t_kg74.c_g else t_kg74.c_obnq8s7_s2 end
);
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
11 changes: 11 additions & 0 deletions tests/integrationtest/t/planner/core/issuetest/planner_issue.test
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,14 @@ update t_kg74 set
where (ref_14.c_z like 'o%fiah')))
where (t_kg74.c_obnq8s7_s2 = case when (t_kg74.c_a1tv2 is NULL) then t_kg74.c_g else t_kg74.c_obnq8s7_s2 end
);

# 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);

0 comments on commit 7df0ce3

Please sign in to comment.