diff --git a/core/trino-main/src/main/java/io/trino/sql/relational/SpecialForm.java b/core/trino-main/src/main/java/io/trino/sql/relational/SpecialForm.java index 7b0a70b65cd27..3af4ebcacd6fa 100644 --- a/core/trino-main/src/main/java/io/trino/sql/relational/SpecialForm.java +++ b/core/trino-main/src/main/java/io/trino/sql/relational/SpecialForm.java @@ -44,15 +44,12 @@ public SpecialForm(Form form, Type returnType, RowExpression... arguments) this(form, returnType, ImmutableList.copyOf(arguments)); } - @JsonCreator - public SpecialForm( - @JsonProperty Form form, - @JsonProperty Type returnType, - @JsonProperty List arguments) + public SpecialForm(Form form, Type returnType, List arguments) { this(form, returnType, arguments, ImmutableList.of()); } + @JsonCreator public SpecialForm(Form form, Type returnType, List arguments, List functionDependencies) { this.form = requireNonNull(form, "form is null"); @@ -67,6 +64,7 @@ public Form getForm() return form; } + @JsonProperty public List getFunctionDependencies() { return functionDependencies; diff --git a/core/trino-main/src/test/java/io/trino/sql/routine/TestSqlFunctions.java b/core/trino-main/src/test/java/io/trino/sql/routine/TestSqlFunctions.java index cc17911e0e525..d50e3c006223f 100644 --- a/core/trino-main/src/test/java/io/trino/sql/routine/TestSqlFunctions.java +++ b/core/trino-main/src/test/java/io/trino/sql/routine/TestSqlFunctions.java @@ -407,6 +407,20 @@ FUNCTION test() assertFunction(sql, handle -> assertThat(handle.invoke()).isEqualTo(2L)); } + @Test + void testSpecialForm() + { + @Language("SQL") String sql = """ + FUNCTION test(a varchar) + RETURNS varchar + BEGIN + RETURN NULLIF(a, 'test'); + END + """; + assertFunction(sql, handle -> assertThat(handle.invoke(utf8Slice("test"))).isEqualTo(null)); + assertFunction(sql, handle -> assertThat(handle.invoke(utf8Slice("test2"))).isEqualTo(utf8Slice("test2"))); + } + @Test void testReuseVariables() {