From 5889f1134efe50192fc0434f03f05d2444cca3eb Mon Sep 17 00:00:00 2001 From: Rohan Yadav Date: Tue, 16 Jul 2019 15:50:08 -0400 Subject: [PATCH] exec: Fix type ambiguity error out for IN and NOT IN. Release note: None --- pkg/sql/distsqlrun/column_exec_setup.go | 8 ++++++++ .../logictest/testdata/logic_test/vectorize | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pkg/sql/distsqlrun/column_exec_setup.go b/pkg/sql/distsqlrun/column_exec_setup.go index 04ce80812863..49a017be1223 100644 --- a/pkg/sql/distsqlrun/column_exec_setup.go +++ b/pkg/sql/distsqlrun/column_exec_setup.go @@ -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) } diff --git a/pkg/sql/logictest/testdata/logic_test/vectorize b/pkg/sql/logictest/testdata/logic_test/vectorize index b3ffd8cab63b..0dff8fd39be9 100644 --- a/pkg/sql/logictest/testdata/logic_test/vectorize +++ b/pkg/sql/logictest/testdata/logic_test/vectorize @@ -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 \ No newline at end of file