Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize function dependencies for SpecialForm #21749

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
wendigo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading