Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Reduce amount of expression objects created during evaluations #15552
Reduce amount of expression objects created during evaluations #15552
Changes from 12 commits
bcdc10b
37b0e01
9ca2652
55583d2
dd44273
90905c7
44f1338
5156236
7e210b5
3719d2b
de51158
e25433d
5ccf462
84461f6
90aa5c3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Curious since we are evaluating this early, does the equals and hash method need to honor this ?
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.
its not included in equals / hashCode as its a computed value from the
value
constructor argument;as a matter of fact...
ConstantExpr
also has anoutputType
field which is also ignored in theequals
/hashCode
stuff - as that is passed in as a constructor parameter - actually this could probably be refactored to remove that field; however I'm not sure what benefits that would give...the other way around could be to build the
ContantExpr
on top of anExprEval
- and useExprEval.value()
to get the inner value - but that approach would not like how the currentBigIntegerExpr
works...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.
I'm not sure how often
Expr
are used in equals/hashcode, my gut says not often since the thing that makes them also usually has the original string which was parsed intoExpr
and is likely cheaper to just use the stringThere 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.
why does this need more than
type == otherType
? Later on we doso if the value is null then it just takes on the other type, so i think being null or not here doesn't matter, because if the value is null and the same type then it is fine
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.
sure - I was too cautious...if it will be
null
; the type will beString
as per the comment above the method - so it will be only==
if the other is also aString
regarding those lines:
if
eval.value() == null
; after the 1st linetype = otherType
; independently from the the 2nd line that will mean that effectivelynumeric(otherType, otherType)
will be called...which made me wonder... can
ExpressionType.getType() == COMPLEX
for this method? if it could this change could alter its behaviour - as earlierDOUBLE
was returned in that caseto avoid changing that behaviour - for now I've changed it to:
should these pass / fail / or shouldn't exists at all?
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.
good question, so this function predates expressions supporting complex types, and shouldn't be used by anything that handles arrays or complex types.
additionally, the comment about nulls always being strings isn't quite as true as it once was, null values coming from columns use the correctly typed null constants, so its mostly null constants and nulls created without additional type information (bestEffortOf) which are string types.
I guess autoDetect should be an invalid exception if it is trying to process complex types, but autoDetect is also only used inside of eval methods as far as I can tell,
Expr.getOutputType
all use other methods in this class likefunction
andoperator
which do handle complex and array types and ensure that they are compatible, so I'm not sure it proves to be much of a problem in practice.