diff --git a/testing/trino-tests/src/test/java/io/trino/tests/TestInlineFunctionQueries.java b/testing/trino-tests/src/test/java/io/trino/tests/TestInlineFunctionQueries.java index ec16db4f49b8..9010a0701569 100644 --- a/testing/trino-tests/src/test/java/io/trino/tests/TestInlineFunctionQueries.java +++ b/testing/trino-tests/src/test/java/io/trino/tests/TestInlineFunctionQueries.java @@ -63,4 +63,34 @@ SELECT my_func(nationkey) """, "SELECT nationkey * 2 FROM nation"); } + + @Test + public void testInlineFunctionWithIf() + { + assertQuery( + """ + WITH FUNCTION my_func(x bigint) + RETURNS bigint + RETURN if(x=1, NULL, x) + SELECT my_func(nationkey) + FROM nation + WHERE nationkey = 1 + """, + "VALUES(cast(NULL as bigint))"); + } + + @Test + public void testInlineFunctionWithNullIf() + { + assertQuery( + """ + WITH FUNCTION my_func(x bigint) + RETURNS bigint + RETURN nullif(x, 1) + SELECT my_func(nationkey) + FROM nation + WHERE nationkey = 1 + """, + "VALUES(cast(NULL as bigint))"); + } }