From ac58f92a97baa60398181a5ec9a7d7e702dc2137 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 6 Apr 2018 08:12:47 +0300 Subject: [PATCH] Fixed error with IN where left hand side is nullable #1846 --- dbms/src/Functions/FunctionsMiscellaneous.cpp | 5 +++++ .../0_stateless/00618_nullable_in.reference | 3 +++ .../queries/0_stateless/00618_nullable_in.sql | 14 ++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00618_nullable_in.reference create mode 100644 dbms/tests/queries/0_stateless/00618_nullable_in.sql diff --git a/dbms/src/Functions/FunctionsMiscellaneous.cpp b/dbms/src/Functions/FunctionsMiscellaneous.cpp index c7267521113..5a5fa63426f 100644 --- a/dbms/src/Functions/FunctionsMiscellaneous.cpp +++ b/dbms/src/Functions/FunctionsMiscellaneous.cpp @@ -729,6 +729,11 @@ public: return std::make_shared(); } + bool useDefaultImplementationForNulls() const override + { + return false; + } + void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) override { /// Second argument must be ColumnSet. diff --git a/dbms/tests/queries/0_stateless/00618_nullable_in.reference b/dbms/tests/queries/0_stateless/00618_nullable_in.reference new file mode 100644 index 00000000000..c8eaff4e6f7 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00618_nullable_in.reference @@ -0,0 +1,3 @@ +1 +100 +10 10 10 diff --git a/dbms/tests/queries/0_stateless/00618_nullable_in.sql b/dbms/tests/queries/0_stateless/00618_nullable_in.sql new file mode 100644 index 00000000000..8e8c26d225d --- /dev/null +++ b/dbms/tests/queries/0_stateless/00618_nullable_in.sql @@ -0,0 +1,14 @@ +SELECT sum(toNullable('a') IN 'a'); +SELECT countIf(number, toNullable('a') IN ('a', 'b')) FROM numbers(100); + +SELECT + uniqExact(x) AS u, + uniqExactIf(x, name = 'a') AS ue, + uniqExactIf(x, name IN ('a', 'b')) AS ui +FROM +( + SELECT + toNullable('a') AS name, + arrayJoin(range(10)) AS x +) +WHERE name = 'a';