query IT
SELECT IF(1 = 2, NULL, 1), IF(2 = 2, NULL, 2)
----
1 null

query ITT
SELECT NULLIF(1, 2), NULLIF(2, 2), NULLIF(NULL, NULL)
----
1 null null

query IIII
SELECT IFNULL(1, 2), IFNULL(NULL, 2), COALESCE(1, 2), COALESCE(NULL, 2)
----
1 2 1 2

statement ok
DROP TABLE IF EXISTS t

statement ok
CREATE TABLE t (a INT PRIMARY KEY)

statement ok
INSERT INTO t VALUES (1), (2), (3)

query IT
SELECT a, CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE 'other' END FROM t ORDER BY a
----
1 one
2 two
3 other

query IT
SELECT a, CASE a WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'other' END FROM t ORDER BY a
----
1 one
2 two
3 other

query III
SELECT a, NULLIF(a, 2), IF(a = 2, NULL, a) FROM t ORDER BY a
----
1 1 1
2 null null
3 3 3

query TTTT
SELECT CASE WHEN false THEN 'one' WHEN true THEN 'two' ELSE 'three' END, CASE 1 WHEN 2 THEN 'two' WHEN 1 THEN 'one' ELSE 'three' END, CASE WHEN false THEN 'one' ELSE 'three' END, CASE WHEN false THEN 'one' END
----
two one three null

query TTTTT
SELECT CASE WHEN 1 = 1 THEN 'one' END, CASE false WHEN 0 = 1 THEN 'one' END, CASE 1 WHEN 2 THEN 'one' ELSE 'three' END, CASE NULL WHEN true THEN 'one' WHEN false THEN 'two' WHEN NULL THEN 'three' ELSE 'four' END, CASE WHEN false THEN 'one' WHEN true THEN 'two' END
----
one one three four two

statement ok
DROP TABLE IF EXISTS tt1;

statement ok
create table tt1(id int primary key, a boolean, b int);

statement ok
insert into tt1 values(0, true, 1),(1, false, 2);

# sqlparser-rs unsupported
# query T
# SELECT CASE WHEN tt1.a THEN last_value([{}, {}, {}]) OVER (PARTITION BY FALSE) WHEN tt1.a THEN [{}] END FROM tt1;
# ----
# [{},{},{}]
# null

statement ok
DROP TABLE tt1

statement ok
DROP TABLE t