Skip to content

Handle CAST in canonicalized LambdaDefinitionExpression#14912

Merged
rongrong merged 1 commit intoprestodb:masterfrom
rongrong:lambda
Jul 29, 2020
Merged

Handle CAST in canonicalized LambdaDefinitionExpression#14912
rongrong merged 1 commit intoprestodb:masterfrom
rongrong:lambda

Conversation

@rongrong
Copy link
Contributor

Include CallExpression return type in canonicalized LambdaDefinitionExpression
so CAST with same input type would not be mistakenly canonicalized.

== RELEASE NOTES ==

General Changes
* Fix LambdaDefinitionExpression canonicalization did not handle CAST

Include CallExpression return type in canonicalized LambdaDefinitionExpression
so CAST with same input type would not be mistakenly canonicalized.
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
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
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
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
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? 😄

Copy link
Contributor

@shixuan-fan shixuan-fan left a comment

Choose a reason for hiding this comment

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

LGTM

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
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? 😄

@rongrong rongrong merged commit fa288b8 into prestodb:master Jul 29, 2020
@caithagoras caithagoras mentioned this pull request Aug 14, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants