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 wrong empty projection (#53235) | tidb-test=pr/2331 #53241

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