Merge pull request #50833 from ClickHouse/transform-tests

Add tests for function "transform"
This commit is contained in:
alesapin 2023-06-10 19:07:03 +02:00 committed by GitHub
commit 826dfe4467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,10 @@
1
1
1
---
1
1
1
1
1
1

View File

@ -0,0 +1,3 @@
select transform(number, [1], [toFloat32(1)], toFloat32(1)) from numbers(3);
SELECT '---';
select transform(number, [3], [toFloat32(1)], toFloat32(1)) from numbers(6);

View File

@ -0,0 +1,9 @@
ZERO
ZERO
ONE
ONE
a
a
\N 0 \N 0 \N
1 1 1 \N 1 1
a \N 3 3 3 3

View File

@ -0,0 +1,40 @@
SELECT transform(0, [0, 1], ['ZERO', 'ONE'], 'DEFAULT') AS result;
SELECT transform(0, [0, 1], ['ZERO', 'ONE'], NULL) AS result;
SELECT CASE 1
WHEN 0 THEN 'ZERO'
WHEN 1 THEN 'ONE'
ELSE 'NONE'
END AS result;
SELECT CASE 1
WHEN 0 THEN NULL
WHEN 1 THEN 'ONE'
ELSE 'NONE'
END AS result;
select
case 1
when 1 then 'a'
else 'b'
end value;
select
case 1
when 1 then 'a'
end value;
SELECT
d,
toInt16OrNull(d),
caseWithExpression(d, 'a', 3, toInt16OrZero(d)) AS case_zero,
caseWithExpression(d, 'a', 3, toInt16OrNull(d)) AS case_null,
if(d = 'a', 3, toInt16OrZero(d)) AS if_zero,
if(d = 'a', 3, toInt16OrNull(d)) AS if_null
FROM
(
SELECT arrayJoin(['', '1', 'a']) AS d
)
ORDER BY
case_zero ASC,
d ASC;