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

exec: Fix type ambiguity error out for IN and NOT IN. #38908

Merged
merged 1 commit into from
Jul 16, 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
8 changes: 8 additions & 0 deletions pkg/sql/distsqlrun/column_exec_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,14 @@ func assertHomogeneousTypes(expr tree.TypedExpr) error {
case *tree.ComparisonExpr:
left := t.TypedLeft().ResolvedType()
right := t.TypedRight().ResolvedType()

// Special rules for IN and NOT IN expressions. The type checker
// handles invalid types for the IN and NOT IN operations at this point,
// and we allow a comparison between t and t tuple.
if t.Operator == tree.In || t.Operator == tree.NotIn {
return nil
}

if !left.Identical(right) {
return errors.Errorf("ComparisonExpr on %s and %s is unhandled", left, right)
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/vectorize
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,21 @@ query I
SELECT * FROM (SELECT count(*) AS x FROM b) WHERE x > 0;
----
4

# Regression test for #38908
statement ok
CREATE TABLE t38908 (x INT)

statement ok
INSERT INTO t38908 VALUES (1)

statement ok
SET experimental_vectorize=always

query I
SELECT * FROM t38908 WHERE x IN (1, 2)
----
1

statement ok
RESET experimental_vectorize