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

CLICKHOUSE-3866 Add case insensitive coalesce, ifnull, nullif. #2752

Merged
merged 1 commit into from
Jul 30, 2018
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: 3 additions & 3 deletions dbms/src/Functions/FunctionsNull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ void registerFunctionsNull(FunctionFactory & factory)
{
factory.registerFunction<FunctionIsNull>();
factory.registerFunction<FunctionIsNotNull>();
factory.registerFunction<FunctionCoalesce>();
factory.registerFunction<FunctionIfNull>();
factory.registerFunction<FunctionNullIf>();
factory.registerFunction<FunctionCoalesce>(FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionIfNull>(FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionNullIf>(FunctionFactory::CaseInsensitive);
factory.registerFunction<FunctionAssumeNotNull>();
factory.registerFunction<FunctionToNullable>();
}
Expand Down
5 changes: 5 additions & 0 deletions dbms/tests/queries/0_stateless/00433_ifnull.reference
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions dbms/tests/queries/0_stateless/00433_ifnull.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions dbms/tests/queries/0_stateless/00435_coalesce.reference
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
\N \N \N 1 1 1 1
\N \N 1
0 Nullable(UInt64)
\N Nullable(UInt64)
2 Nullable(UInt64)
Expand Down
2 changes: 2 additions & 0 deletions dbms/tests/queries/0_stateless/00435_coalesce.sql
Original file line number Diff line number Diff line change
@@ -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;