Skip to content

Commit

Permalink
Add tests for inline functions
Browse files Browse the repository at this point in the history
  • Loading branch information
guyco33 committed Dec 6, 2023
1 parent 17054fa commit eb84d18
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))");
}
}

0 comments on commit eb84d18

Please sign in to comment.