This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 3e256e1 [CALCITE-3794] Return directly if there is no pulled up
predicate
3e256e1 is described below
commit 3e256e12ff91ab26f68ec86498bd0af57f91a03c
Author: Chunwei Lei <[email protected]>
AuthorDate: Thu Feb 13 16:25:03 2020 +0800
[CALCITE-3794] Return directly if there is no pulled up predicate
Also some cosmetic changes.
---
.../main/java/org/apache/calcite/rex/RexSimplify.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
index ce37244..4a1fee7 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
@@ -629,8 +629,8 @@ public class RexSimplify {
// UnknownAs.FALSE corresponds to x IS TRUE evaluation
// UnknownAs.TRUE to x IS NOT FALSE
// Note that both UnknownAs.TRUE and UnknownAs.FALSE only changes the
meaning of Unknown
- // (1) if we are already in UnknownAs.FALSE mode; x IS TRUE can be
simiplified to x
- // (2) similarily in UnknownAs.TRUE mode ; x IS NOT FALSE can be
simplified to x
+ // (1) if we are already in UnknownAs.FALSE mode; x IS TRUE can be
simplified to x
+ // (2) similarily in UnknownAs.TRUE mode; x IS NOT FALSE can be simplified
to x
// (3) x IS FALSE could be rewritten to (NOT x) IS TRUE and from there the
1. rule applies
// (4) x IS NOT TRUE can be rewritten to (NOT x) IS NOT FALSE and from
there the 2. rule applies
if (kind == SqlKind.IS_TRUE && unknownAs == RexUnknownAs.FALSE) {
@@ -1571,6 +1571,9 @@ public class RexSimplify {
private <C extends Comparable<C>> RexNode simplifyUsingPredicates(RexNode e,
Class<C> clazz) {
+ if (predicates.pulledUpPredicates.isEmpty()) {
+ return e;
+ }
final Comparison comparison = Comparison.of(e);
// Check for comparison with null values
if (comparison == null
@@ -1738,7 +1741,6 @@ public class RexSimplify {
// - if it is not an IS_NOT_NULL (i.e. it is a NOT_EQUALS):
check comparison values
if (prevNotEquals.getKind() != SqlKind.IS_NOT_NULL) {
final Comparable comparable1 =
notEqualsComparison.literal.getValue();
- //noinspection ConstantConditions
final Comparable comparable2 =
Comparison.of(prevNotEquals).literal.getValue();
//noinspection unchecked
if (comparable1.compareTo(comparable2) != 0) {
@@ -1978,7 +1980,7 @@ public class RexSimplify {
case MILLISECOND:
case MICROSECOND:
if (inner == TimeUnit.QUARTER) {
- return outer == TimeUnit.YEAR || outer == TimeUnit.QUARTER;
+ return outer == TimeUnit.YEAR;
}
return outer.ordinal() <= inner.ordinal();
}
@@ -2014,7 +2016,7 @@ public class RexSimplify {
if (p == null) {
rangeTerms.put(ref,
Pair.of(range(comparison, v0),
- (List<RexNode>) ImmutableList.of(term)));
+ ImmutableList.of(term)));
} else {
// Exists
boolean removeUpperBound = false;
@@ -2029,7 +2031,7 @@ public class RexSimplify {
}
rangeTerms.put(ref,
Pair.of(Range.singleton(v0),
- (List<RexNode>) ImmutableList.of(term)));
+ ImmutableList.of(term)));
// remove
for (RexNode e : p.right) {
replaceLast(terms, e, trueLiteral);
@@ -2187,7 +2189,7 @@ public class RexSimplify {
}
newBounds.add(term);
rangeTerms.put(ref,
- Pair.of(r, (List<RexNode>) newBounds.build()));
+ Pair.of(r, newBounds.build()));
} else if (removeLowerBound) {
ImmutableList.Builder<RexNode> newBounds = ImmutableList.builder();
for (RexNode e : p.right) {
@@ -2199,7 +2201,7 @@ public class RexSimplify {
}
newBounds.add(term);
rangeTerms.put(ref,
- Pair.of(r, (List<RexNode>) newBounds.build()));
+ Pair.of(r, newBounds.build()));
}
}
// Default