mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Merge pull request #50833 from ClickHouse/transform-tests
Add tests for function "transform"
This commit is contained in:
commit
826dfe4467
10
tests/queries/0_stateless/02786_transform_float.reference
Normal file
10
tests/queries/0_stateless/02786_transform_float.reference
Normal file
@ -0,0 +1,10 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
---
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
3
tests/queries/0_stateless/02786_transform_float.sql
Normal file
3
tests/queries/0_stateless/02786_transform_float.sql
Normal 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);
|
9
tests/queries/0_stateless/02787_transform_null.reference
Normal file
9
tests/queries/0_stateless/02787_transform_null.reference
Normal 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
|
40
tests/queries/0_stateless/02787_transform_null.sql
Normal file
40
tests/queries/0_stateless/02787_transform_null.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user