diff --git a/planner/core/issuetest/BUILD.bazel b/planner/core/issuetest/BUILD.bazel index 18954ab15a45a..6bcf719748509 100644 --- a/planner/core/issuetest/BUILD.bazel +++ b/planner/core/issuetest/BUILD.bazel @@ -6,6 +6,6 @@ go_test( srcs = ["planner_issue_test.go"], flaky = True, race = "on", - shard_count = 11, + shard_count = 12, deps = ["//testkit"], ) diff --git a/planner/core/issuetest/planner_issue_test.go b/planner/core/issuetest/planner_issue_test.go index 4851511315bb5..833ed09f115c9 100644 --- a/planner/core/issuetest/planner_issue_test.go +++ b/planner/core/issuetest/planner_issue_test.go @@ -262,3 +262,18 @@ func TestIssue50614(t *testing.T) { ), ) } + +func TestIssue49109(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test;") + tk.MustExec("drop table if exists t0, t1;") + tk.MustExec("CREATE TABLE t0(c0 NUMERIC);") + tk.MustExec("CREATE TABLE t1(c0 NUMERIC);") + tk.MustExec("INSERT INTO t0 VALUES (0), (NULL), (1), (2);") + tk.MustExec("INSERT INTO t1(c0) VALUES (NULL), (3), (4), (5);") + tk.MustExec("drop view if exists v0;") + tk.MustExec("CREATE definer='root'@'localhost' VIEW v0(c0) AS SELECT t0.c0 FROM t0;") + + tk.MustQuery("SELECT t0.c0 FROM v0, t0 LEFT JOIN t1 ON t0.c0 WHERE ((INET_ATON('5V')) IS NULL);").Check(testkit.Rows("0", "0", "0", "0", "", "", "", "", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2")) +} diff --git a/planner/core/rule_column_pruning.go b/planner/core/rule_column_pruning.go index 4c1b507a5042f..4371737269524 100644 --- a/planner/core/rule_column_pruning.go +++ b/planner/core/rule_column_pruning.go @@ -99,6 +99,7 @@ func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column, opt if err != nil { return nil, err } + addConstOneForEmptyProjection(p.children[0]) return p, nil }