-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
opt: fold unary minus operations #26926
Conversation
Review status: complete! 0 of 0 LGTMs obtained pkg/sql/opt/norm/custom_funcs.go, line 766 at r1 (raw file):
I don't think we should duplicate this logic. We should be using the logic in pkg/sql/opt/norm/custom_funcs.go, line 777 at r1 (raw file):
What if the existing value is -MIN_INT, so there's no way to negate it without overflow? I think you need: @radu, what do you think the best approach would be? Comments from Reviewable |
Review status: complete! 0 of 0 LGTMs obtained pkg/sql/opt/norm/custom_funcs.go, line 766 at r1 (raw file): Previously, andy-kimball (Andy Kimball) wrote…
Pulled it out into functions. pkg/sql/opt/norm/custom_funcs.go, line 777 at r1 (raw file): Previously, andy-kimball (Andy Kimball) wrote…
Done, I did the Comments from Reviewable |
Reviewed 1 of 4 files at r1, 7 of 7 files at r2. pkg/sql/opt/norm/testdata/rules/combo, line 138 at r2 (raw file):
Did you run pkg/sql/sem/tree/eval.go, line 67 at r2 (raw file):
Maybe say "should not be called with math.MinInt64, since that will cause integer overflow" or something like that... Comments from Reviewable |
a228ab5
to
4d29cae
Compare
As discussed on Slack I removed Review status: complete! 0 of 0 LGTMs obtained (and 1 stale) pkg/sql/sem/tree/eval.go, line 67 at r2 (raw file): Previously, rytaft wrote…
Ended up removing this pkg/sql/opt/norm/testdata/rules/combo, line 138 at r2 (raw file): Previously, rytaft wrote…
Done. Comments from Reviewable |
Reviewed 5 of 5 files at r3. pkg/sql/opt/memo/typing.go, line 353 at r3 (raw file):
I'm not convinced this is the right place for this function. Why not just put it in Comments from Reviewable |
Review status: complete! 0 of 0 LGTMs obtained (and 1 stale) pkg/sql/opt/memo/typing.go, line 353 at r3 (raw file): Previously, rytaft wrote…
This function doesn't really fit perfectly in either place. We shouldn't be searching for overloads in Comments from Reviewable |
Review status: complete! 0 of 0 LGTMs obtained (and 1 stale) pkg/sql/opt/memo/typing.go, line 353 at r3 (raw file): Previously, andy-kimball (Andy Kimball) wrote…
ok sounds good Comments from Reviewable |
1d8b5d3
to
d9a4274
Compare
TFTRs, going to rebase+merge this |
This commit introduces a new rule, FoldUnaryMinus, which transforms constant expressions of the form (UnaryMinus x) to -x. There were some cases around this which would result in us not correctly recognizing expressions like -1:::FLOAT as constant, causing us to perform a full table scan instead of a point lookup. Release note: None
bors r+ |
26926: opt: fold unary minus operations r=justinj a=justinj This commit introduces a new rule, FoldUnaryMinus, which transforms constant expressions of the form (UnaryMinus x) to -x. There were some cases around this which would result in us not correctly recognizing expressions like -1:::FLOAT as constant, causing us to perform a full table scan instead of a point lookup. Release note: None Co-authored-by: Justin Jaffray <[email protected]>
Build succeeded |
This commit introduces a new rule, FoldUnaryMinus, which transforms
constant expressions of the form (UnaryMinus x) to -x.
There were some cases around this which would result in us not correctly
recognizing expressions like -1:::FLOAT as constant, causing us to
perform a full table scan instead of a point lookup.
Release note: None