From f3468e98135e35605eedab67bfbfbd8a4ba43318 Mon Sep 17 00:00:00 2001 From: ap11 Date: Mon, 30 Jul 2018 12:36:27 +0300 Subject: [PATCH] Add case insensitive coalesce ifnull, nullif. --- dbms/src/Functions/FunctionsNull.cpp | 6 +++--- dbms/tests/queries/0_stateless/00433_ifnull.reference | 5 +++++ dbms/tests/queries/0_stateless/00433_ifnull.sql | 2 ++ dbms/tests/queries/0_stateless/00435_coalesce.reference | 1 + dbms/tests/queries/0_stateless/00435_coalesce.sql | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dbms/src/Functions/FunctionsNull.cpp b/dbms/src/Functions/FunctionsNull.cpp index af2831db383..979c92823ff 100644 --- a/dbms/src/Functions/FunctionsNull.cpp +++ b/dbms/src/Functions/FunctionsNull.cpp @@ -19,9 +19,9 @@ void registerFunctionsNull(FunctionFactory & factory) { factory.registerFunction(); factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); - factory.registerFunction(); + factory.registerFunction(FunctionFactory::CaseInsensitive); + factory.registerFunction(FunctionFactory::CaseInsensitive); + factory.registerFunction(FunctionFactory::CaseInsensitive); factory.registerFunction(); factory.registerFunction(); } diff --git a/dbms/tests/queries/0_stateless/00433_ifnull.reference b/dbms/tests/queries/0_stateless/00433_ifnull.reference index c1a59dec60e..4cf982b2116 100644 --- a/dbms/tests/queries/0_stateless/00433_ifnull.reference +++ b/dbms/tests/queries/0_stateless/00433_ifnull.reference @@ -28,3 +28,8 @@ x Nullable(String) 1 UInt8 1 UInt8 \N Nullable(Nothing) +0 Nullable(String) +-1 Nullable(String) +2 Nullable(String) +3 Nullable(String) +4 Nullable(String) diff --git a/dbms/tests/queries/0_stateless/00433_ifnull.sql b/dbms/tests/queries/0_stateless/00433_ifnull.sql index cad3eeba534..9071305a87a 100644 --- a/dbms/tests/queries/0_stateless/00433_ifnull.sql +++ b/dbms/tests/queries/0_stateless/00433_ifnull.sql @@ -17,3 +17,5 @@ SELECT ifNull(nullIf(toString(number), '1'), nullIf(toString(-number), '-3')) AS SELECT ifNull(NULL, 1) AS res, toTypeName(res); SELECT ifNull(1, NULL) AS res, toTypeName(res); SELECT ifNull(NULL, NULL) AS res, toTypeName(res); + +SELECT IFNULL(NULLIF(toString(number), '1'), NULLIF(toString(-number), '-3')) AS res, toTypeName(res) FROM system.numbers LIMIT 5; diff --git a/dbms/tests/queries/0_stateless/00435_coalesce.reference b/dbms/tests/queries/0_stateless/00435_coalesce.reference index 20b8288b09c..b236c89c865 100644 --- a/dbms/tests/queries/0_stateless/00435_coalesce.reference +++ b/dbms/tests/queries/0_stateless/00435_coalesce.reference @@ -1,4 +1,5 @@ \N \N \N 1 1 1 1 +\N \N 1 0 Nullable(UInt64) \N Nullable(UInt64) 2 Nullable(UInt64) diff --git a/dbms/tests/queries/0_stateless/00435_coalesce.sql b/dbms/tests/queries/0_stateless/00435_coalesce.sql index 7c1c519bcb2..3744f5ff290 100644 --- a/dbms/tests/queries/0_stateless/00435_coalesce.sql +++ b/dbms/tests/queries/0_stateless/00435_coalesce.sql @@ -1,6 +1,8 @@ SELECT coalesce(), coalesce(NULL), coalesce(NULL, NULL), coalesce(1), coalesce(1, NULL), coalesce(NULL, 1), coalesce(NULL, 1, NULL); +SELECT COALESCE(), COALESCE(NULL), COALESCE(1, NULL); + SELECT coalesce(number % 2 = 0 ? number : NULL, number % 3 = 0 ? number : NULL, number % 5 = 0 ? number : NULL) AS res, toTypeName(res) FROM system.numbers LIMIT 15; SELECT coalesce(number % 2 = 0 ? number : NULL, number % 3 = 0 ? number : NULL, number) AS res, toTypeName(res) FROM system.numbers LIMIT 15; SELECT coalesce(number % 2 = 0 ? number : NULL, number % 3 = 0 ? number : NULL, 100) AS res, toTypeName(res) FROM system.numbers LIMIT 15;