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

coldata: respect SelOnDest flag when setting nulls #40606

Merged
merged 1 commit into from
Sep 9, 2019
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
6 changes: 6 additions & 0 deletions pkg/col/coldata/vec_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ func _COPY_WITH_SEL(
nulls := args.Src.Nulls()
for i, selIdx := range sel[args.SrcStartIdx:args.SrcEndIdx] {
if nulls.NullAt64(uint64(selIdx)) {
// {{if .SelOnDest}}
// Remove an unused warning in some cases.
_ = i
m.nulls.SetNull64(uint64(selIdx))
// {{else}}
m.nulls.SetNull64(uint64(i) + args.DestIdx)
// {{end}}
} else {
v := execgen.UNSAFEGET(fromCol, int(selIdx))
// {{if .SelOnDest}}
Expand Down
14 changes: 14 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/dist_vectorize
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,17 @@ EXPLAIN (VEC, VERBOSE) SELECT count(*) FROM kv NATURAL INNER HASH JOIN kv kv2
└ *exec.HashRouter
└ *exec.CancelChecker
└ *distsqlrun.colBatchScan

# Test that SelOnDest flag of coldata.SliceArgs is respected when setting
# nulls.
statement ok
CREATE TABLE t1(a INT PRIMARY KEY, b INT)

statement ok
INSERT INTO t1 VALUES (1, NULL), (2, NULL)

query I rowsort
SELECT CASE WHEN a>1 THEN b*2 ELSE b*10 END FROM t1
----
NULL
NULL