[CALCITE-7694] RexSimplify should simplify comparisons involving RAND() using its [0, 1) range - #5161
[CALCITE-7694] RexSimplify should simplify comparisons involving RAND() using its [0, 1) range#5161xuzifu666 wants to merge 5 commits into
Conversation
| } | ||
|
|
||
| /** Flips a comparison operator. e.g., GREATER_THAN → LESS_THAN. */ | ||
| private static SqlKind flipComparison(SqlKind kind) { |
There was a problem hiding this comment.
This method should not be necessary, there is already SqlKind#reverse which seems to serve the same purpose
There was a problem hiding this comment.
Good catch!SqlKind#reverse() does serve the same purpose. It maps the four ordering comparisons identically, and for EQUALS/NOT_EQUALS it returns the kind unchanged, which is exactly what we want since a = b ⇔ b = a and a <> b ⇔ b <> a. I've removed flipComparison and replaced its three call sites with kind.reverse(). Thanks!
| } | ||
|
|
||
| /** Checks if a RexNode is a numeric literal (possibly wrapped in CAST). */ | ||
| private static boolean isNumericLiteral(RexNode node) { |
There was a problem hiding this comment.
Could this be simplified by (re)using SqlTypeUtil#isNumeric ?
There was a problem hiding this comment.
Done. Replaced the manual type-family check with SqlTypeUtil.isNumeric(stripped.getType()), which is equivalent (isExactNumeric || isApproximateNumeric) and reads more clearly. isNumericLiteral is now just a LITERAL check plus SqlTypeUtil.isNumeric.
|
|
That's a lot of code. Does anyone need this? |
|
See jira. I don't think we should do this. |



jira: https://issues.apache.org/jira/browse/CALCITE-7694