-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Refactor ExpressionOptimizer #24287
base: master
Are you sure you want to change the base?
Refactor ExpressionOptimizer #24287
Conversation
5409857
to
7f4264b
Compare
Don't forget to update the release note with the correct PR # |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this refactor, LGTM!
{ | ||
RowExpressionInterpreter interpreter = new RowExpressionInterpreter(expression, metadata.getFunctionAndTypeManager(), session, level); | ||
return interpreter.optimize(variableResolver::apply); | ||
return toRowExpression(expression.getSourceLocation(), interpreter.optimize(variableResolver::apply), expression.getType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to change RowExpressionInterpreter to return a RowExpression instead of an object (seems like basically it requires wrapping any "values" in constant expressions, and then changing anything that calls it to expect that to happen). Returning an Object that could be anything and leaving it to the caller be able to handle it seems like a bad pattern to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this change is still an improvement, so i'm fine with merging this first.
Description
Refactor
ExpressionOptimizer
to consistently returnRowExpression
. Before,ExpressionOptimizer
would returnRowExpression
only for the method which did not take in a variable resolver function. I cannot discern a good reason for this. By refactoring this interface and making them both returnRowExpression
, and documenting that the two methods are equivalent when an identity function is used for the variable resolver, it becomes possible to share code that uses both methods.Motivation and Context
This is to help address PR review feedback here: #24144 (comment)
Impact
Code refactoring. Implementations of
ExpressionOptimizer
in the SPI will need to update their plugins to accommodate the changed API.Test Plan
Unit tests
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.