Skip to content

Commit

Permalink
Serialize function dependencies for SpecialForm
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Apr 29, 2024
1 parent 1eb4676 commit 32efe57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<RowExpression> arguments)
public SpecialForm(Form form, Type returnType, List<RowExpression> arguments)
{
this(form, returnType, arguments, ImmutableList.of());
}

@JsonCreator
public SpecialForm(Form form, Type returnType, List<RowExpression> arguments, List<ResolvedFunction> functionDependencies)
{
this.form = requireNonNull(form, "form is null");
Expand All @@ -67,6 +64,7 @@ public Form getForm()
return form;
}

@JsonProperty
public List<ResolvedFunction> getFunctionDependencies()
{
return functionDependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 32efe57

Please sign in to comment.