Skip to content

Commit

Permalink
planner: fix wrong empty projection (#53235) (#53239)
Browse files Browse the repository at this point in the history
close #49109
  • Loading branch information
ti-chi-bot authored Jun 13, 2024
1 parent 409465c commit 2c0584a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion planner/core/issuetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ go_test(
srcs = ["planner_issue_test.go"],
flaky = True,
race = "on",
shard_count = 11,
shard_count = 12,
deps = ["//testkit"],
)
15 changes: 15 additions & 0 deletions planner/core/issuetest/planner_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<nil>", "<nil>", "<nil>", "<nil>", "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"))
}
1 change: 1 addition & 0 deletions planner/core/rule_column_pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 2c0584a

Please sign in to comment.