-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CALCITE-4159] Simplify always-true expressions (such as LIKE '%') to TRUE #2105
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
Conversation
/** Returns whether this predicate can while simplifying other OR | ||
* operands. */ | ||
default boolean allowedInOr(RelOptPredicateList predicates) { | ||
return true; |
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.
It seems to lack some words between can
and while
.
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 catch. i'll fix.
core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
Show resolved
Hide resolved
protected RexNode like(RexNode ref, RexNode pattern, RexNode escape) { | ||
return rexBuilder.makeCall(SqlStdOperatorTable.LIKE, ref, pattern, escape); | ||
} | ||
|
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.
What does this method mean? Could you add some comments?
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 disagree. There are lots of surrounding methods with a similar pattern. They are protected methods in a test case. Javadoc would not add anything.
// is not null. | ||
RexCall call = (RexCall) e; | ||
if (call.getOperands().get(1) instanceof RexLiteral) { | ||
return isEffectivelyNotNull(call.getOperands().get(0)); |
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.
do we also need to consider cases such as '10 > ref' here?
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 missed this comment. I'll address during CALCITE-4173.
016ce74
to
f8fa1f5
Compare
We can now simplify 'a = 1 or a <> 1' to 'true'. To achieve this, we simplify the second term in a context where we know 'a = 1' is false. This entails a RangeSet inside simplifyUsingPredicates, so that we can represent <> the same way that we represent =, > etc. All of the others are a Range, but <> requires a two-entry RangeSet ('a < 1 or a > 1').
… TRUE RexSimplify needs to recognize that the following expressions can be simplified to TRUE: * c < 0 OR c >= 0 OR c IS NULL * c < 2 OR c > 0 OR c IS NULL * c LIKE '%' OR c IS NULL To enable this fix, we pull 'IS NULL' terms to the front of a list of OR-terms, so that by the time the subsequent terms are reached they know that the term's value is not NULL.
…at represents a set of values or ranges Obsolete use of IN in RexCall.
f8fa1f5
to
d1e0a98
Compare
… TRUE RexSimplify needs to recognize that the following expressions can be simplified to TRUE: * c < 0 OR c >= 0 OR c IS NULL * c < 2 OR c > 0 OR c IS NULL * c LIKE '%' OR c IS NULL To enable this fix, we pull 'IS NULL' terms to the front of a list of OR-terms, so that by the time the subsequent terms are reached they know that the term's value is not NULL. Close apache#2105
No description provided.