Skip to content
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 @@ -133,7 +133,7 @@ public CanonicalizeExpression(List<String> arguments, List<Type> argumentTypes)
@Override
public String visitCall(CallExpression call, Void context)
{
return format("%s.%s(%s)", call.getFunctionHandle().getFunctionNamespace(), call.getDisplayName(), String.join(", ", call.getArguments().stream().map(e -> e.accept(this, null)).collect(Collectors.toList())));
return format("%s.%s(%s):%s", call.getFunctionHandle().getFunctionNamespace(), call.getDisplayName(), String.join(", ", call.getArguments().stream().map(e -> e.accept(this, null)).collect(Collectors.toList())), call.getType());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to do it only for CAST so we don't accidentally cause other issues?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all other functions, return type should be the same if name and input type is the same. So this is just adding a little overhead. However, in any case that return type is different, it would be wrong to canonicalize them. So I think it's safe to keep it for all functions. Also not all cast functions are just called "cast". We don't really have an error prone way to identify all cast functions...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably good to have one parameter per line now? 😄

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ public void testTryLambdaRepeated()
assertQuery("SELECT try(10 / a), try(10 / a) FROM (VALUES 5) t(a)", "SELECT 2, 2");
}

@Test
public void testTryLambdaWithCast()
{
assertQuery(
"SELECT IF(TRY(CAST(a AS INT)) IN (1, 5), TRY(CAST(b AS DOUBLE)), 0.0) FROM (VALUES (varchar'1', varchar'2.1'), (varchar'5', varchar'3.4')) t(a, b)",
"VALUES 2.1, 3.4");
}

@Test
public void testNonDeterministicFilter()
{
Expand Down