Repository navigation
Conversation
Constant propagation replaces a column with a column or constant that equality says is equal. DOUBLE equality treats +0 and -0 as equal, but ATAN2 and a cast of a real value to a string tell them apart, so the substitution changed the result of a predicate such as ATAN2(y, -1) > 0 derived from x = y. Skip the substitution when the predicate contains such a function: in tryToReplaceCond for column to column, and before the two ColumnSubstitute calls for a zero real constant. Fixes pingcap#73686 Signed-off-by: Aryan Deshmukh <[email protected]>
|
Hi @A-RYAN-1. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What problem does this PR solve?
Issue Number: close #73686
Problem Summary: constant propagation derives
ATAN2(y, -1) > 0fromx = yand drops rows, because DOUBLE equality treats +0 and -0 as equal whileATAN2and a cast of a real value to a string tell them apart. Withx double, y double as (-x)and a stored 0,select x = y, atan2(x, -1) > 0, atan2(y, -1) > 0returns1 1 0, so the substitution changes the answer.What changed and how does it work?
Skip the substitution when the predicate contains a function that can observe the sign of a zero (
ATAN2, two-argumentATAN, and a cast from a real type to a string type). It is applied intryToReplaceCondfor column to column, and before the twoColumnSubstitutecalls (inner and outer join solvers) when the substituted constant is a real zero of either sign. Other predicates are still propagated, which the test checks withx + 1 > 0. The check is one function-name comparison per node.Not covered: decimal and JSON casts gave the same result for both zeros in a probe, so they are not treated as sinks, and
json_arrayis not covered.Check List
Tests
TestSignedZeroPropagationinpkg/expression/test/constantpropagationfails on the base and passes with this change.Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
0and-0. Sign-sensitive expressions and casts now retain the correct behavior in filters and join conditions, while sign-insensitive calculations can still be optimized.