[calcite] branch master updated: [CALCITE-5000] Expand `AGGREGATE_REDUCE_FUNCTIONS`, when arg of agg-call exists in the aggregate's group

2022-04-14 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 c8d1cb5a1 [CALCITE-5000] Expand `AGGREGATE_REDUCE_FUNCTIONS`, when arg 
of agg-call exists in the aggregate's group
c8d1cb5a1 is described below

commit c8d1cb5a1e1b1dd98966c29308bc6b1aed245501
Author: xurenhe 
AuthorDate: Wed Feb 9 16:09:55 2022 +0800

[CALCITE-5000] Expand `AGGREGATE_REDUCE_FUNCTIONS`, when arg of agg-call 
exists in the aggregate's group
---
 .../rel/rules/AggregateReduceFunctionsRule.java| 62 +-
 .../org/apache/calcite/test/RelOptRulesTest.java   | 12 +
 .../org/apache/calcite/test/RelOptRulesTest.xml| 32 +--
 3 files changed, 100 insertions(+), 6 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java
 
b/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java
index 522835f8a..6cdf849be 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java
@@ -20,12 +20,15 @@ import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptRuleCall;
 import org.apache.calcite.plan.RelOptRuleOperand;
 import org.apache.calcite.plan.RelRule;
+import org.apache.calcite.rel.RelCollations;
+import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Aggregate;
 import org.apache.calcite.rel.core.AggregateCall;
 import org.apache.calcite.rel.logical.LogicalAggregate;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexInputRef;
 import org.apache.calcite.rex.RexLiteral;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.sql.SqlAggFunction;
@@ -178,6 +181,37 @@ public class AggregateReduceFunctionsRule
 && config.extraCondition().test(call);
   }
 
+  /** Returns whether this rule can reduce some agg-call,
+   * which its arg exists in the aggregate's group. */
+  public boolean canReduceAggCallByGrouping(Aggregate oldAggRel, AggregateCall 
call) {
+if (!Aggregate.isSimple(oldAggRel)) {
+  return false;
+}
+if (call.hasFilter() || call.distinctKeys != null || call.collation != 
RelCollations.EMPTY) {
+  return false;
+}
+final List argList = call.getArgList();
+if (argList.size() != 1) {
+  return false;
+}
+if (!oldAggRel.getGroupSet().asSet().contains(argList.get(0))) {
+  // arg doesn't exist in aggregate's group.
+  return false;
+}
+final SqlKind kind = call.getAggregation().getKind();
+switch (kind) {
+case AVG:
+case MAX:
+case MIN:
+case ANY_VALUE:
+case FIRST_VALUE:
+case LAST_VALUE:
+  return true;
+default:
+  return false;
+}
+  }
+
   /**
* Reduces calls to functions AVG, SUM, STDDEV_POP, STDDEV_SAMP, VAR_POP,
* VAR_SAMP, COVAR_POP, COVAR_SAMP, REGR_SXX, REGR_SYY if the function is
@@ -228,7 +262,8 @@ public class AggregateReduceFunctionsRule
 }
 newAggregateRel(relBuilder, oldAggRel, newCalls);
 newCalcRel(relBuilder, oldAggRel.getRowType(), projList);
-ruleCall.transformTo(relBuilder.build());
+final RelNode build = relBuilder.build();
+ruleCall.transformTo(build);
   }
 
   private RexNode reduceAgg(
@@ -237,7 +272,12 @@ public class AggregateReduceFunctionsRule
   List newCalls,
   Map aggCallMapping,
   List inputExprs) {
-if (canReduce(oldCall)) {
+if (canReduceAggCallByGrouping(oldAggRel, oldCall)) {
+  // replace original MAX/MIN/AVG/ANY_VALUE/FIRST_VALUE/LAST_VALUE(x) with
+  // target field of x, when x exists in group
+  final RexNode reducedNode = reduceAggCallByGrouping(oldAggRel, oldCall);
+  return reducedNode;
+} else if (canReduce(oldCall)) {
   final Integer y;
   final Integer x;
   final SqlKind kind = oldCall.getAggregation().getKind();
@@ -572,6 +612,24 @@ public class AggregateReduceFunctionsRule
 oldCall.getType(), result);
   }
 
+  private static RexNode reduceAggCallByGrouping(
+  Aggregate oldAggRel,
+  AggregateCall oldCall) {
+
+final RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
+final List oldGroups = oldAggRel.getGroupSet().asList();
+final Integer firstArg = oldCall.getArgList().get(0);
+final int index = oldGroups.lastIndexOf(firstArg);
+assert index >= 0;
+
+final RexInputRef refByGroup = RexInputRef.of(index, 
oldAggRel.getRowType().getFieldList());
+if (refByGroup.getType().equals(oldCall.getType())) {
+  return refByGroup;
+} else {
+  return rexBuilder.makeCast(oldCall.getType(), refByGroup);
+}
+  }
+

[calcite] branch master updated: [CALCITE-5032] RelOptUtil#splitJoinCondition returns wrong when there is no equal condition

2022-04-14 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 fe9766aaa [CALCITE-5032] RelOptUtil#splitJoinCondition returns wrong 
when there is no equal condition
fe9766aaa is described below

commit fe9766aaa5739f59f757206c57c1b9cc071cd6f6
Author: Benchao Li 
AuthorDate: Sun Mar 27 21:49:16 2022 +0800

[CALCITE-5032] RelOptUtil#splitJoinCondition returns wrong when there is no 
equal condition
---
 .../java/org/apache/calcite/plan/RelOptUtil.java   | 35 --
 .../org/apache/calcite/plan/RelOptUtilTest.java| 22 ++
 2 files changed, 22 insertions(+), 35 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index f1e8b13b7..c7b5c7cbc 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -1387,41 +1387,6 @@ public abstract class RelOptUtil {
 }
   }
 
-  if ((rangeOp == null)
-  && ((leftKey == null) || (rightKey == null))) {
-// no equality join keys found yet:
-// try transforming the condition to
-// equality "join" conditions, e.g.
-// f(LHS) > 0 ===> ( f(LHS) > 0 ) = TRUE,
-// and make the RHS produce TRUE, but only if we're strictly
-// looking for equi-joins
-final ImmutableBitSet projRefs = InputFinder.bits(condition);
-leftKey = null;
-rightKey = null;
-
-boolean foundInput = false;
-for (int i = 0; i < inputs.size() && !foundInput; i++) {
-  if (inputsRange[i].contains(projRefs)) {
-leftInput = i;
-leftFields = inputs.get(leftInput).getRowType().getFieldList();
-
-leftKey = condition.accept(
-new RelOptUtil.RexInputConverter(
-rexBuilder,
-leftFields,
-leftFields,
-adjustments));
-
-rightKey = rexBuilder.makeLiteral(true);
-
-// effectively performing an equality comparison
-kind = SqlKind.EQUALS;
-
-foundInput = true;
-  }
-}
-  }
-
   if ((leftKey != null) && (rightKey != null)) {
 // found suitable join keys
 // add them to key list, ensuring that if there is a
diff --git a/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java 
b/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
index ce571c33c..2f22e78ee 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
@@ -56,6 +56,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -285,6 +286,27 @@ class RelOptUtilTest {
 relBuilder.literal(true));
   }
 
+  @Test void testSplitJoinConditionWithoutEqualCondition() {
+final List sysFieldList = Collections.emptyList();
+final List> joinKeys = Arrays.asList(new ArrayList<>(), new 
ArrayList<>());
+final RexNode joinCondition = relBuilder.equals(
+RexInputRef.of(0, empDeptJoinRelFields),
+relBuilder.literal(1));
+final RexNode result = RelOptUtil.splitJoinCondition(
+sysFieldList,
+Arrays.asList(empScan, deptScan),
+joinCondition,
+joinKeys,
+null,
+null
+);
+final List> expectedJoinKeys = Arrays.asList(
+Collections.emptyList(),
+Collections.emptyList());
+assertEquals(joinKeys, expectedJoinKeys);
+assertEquals(result, joinCondition);
+  }
+
   /**
* Test {@link RelOptUtil#splitJoinCondition(RelNode, RelNode, RexNode, 
List, List, List)}
* where the join condition contains just one which is a IS NOT DISTINCT 
operator.



[calcite] branch master updated: Revert "[CALCITE-4817] Expand SubstitutionVisitor of Aggregate with max/min, which column is the group by list of target (xurenhe)"

2021-10-08 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 dbaf22c  Revert "[CALCITE-4817] Expand SubstitutionVisitor of 
Aggregate with max/min, which column is the group by list of target (xurenhe)"
dbaf22c is described below

commit dbaf22c1ab93de174560f326e516e57727318d19
Author: Haisheng Yuan 
AuthorDate: Fri Oct 8 15:24:40 2021 -0700

Revert "[CALCITE-4817] Expand SubstitutionVisitor of Aggregate with 
max/min, which column is the group by list of target (xurenhe)"

This reverts commit 74e97780add051cb71a122075e5bcbceb40e889c.
---
 .../apache/calcite/plan/SubstitutionVisitor.java   | 10 ++
 .../MaterializedViewSubstitutionVisitorTest.java   | 41 --
 2 files changed, 3 insertions(+), 48 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java 
b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
index 25423b4..c0899fa 100644
--- a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
+++ b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
@@ -61,7 +61,6 @@ import org.apache.calcite.tools.RelBuilderFactory;
 import org.apache.calcite.util.ControlFlowException;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Litmus;
-import org.apache.calcite.util.Optionality;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 import org.apache.calcite.util.mapping.Mapping;
@@ -1936,15 +1935,12 @@ public class SubstitutionVisitor {
   }
   final List aggregateCalls = new ArrayList<>();
   for (AggregateCall aggregateCall : query.aggCalls) {
-final SqlAggFunction aggregation = aggregateCall.getAggregation();
-if ((aggregateCall.isDistinct()
-|| aggregation.getDistinctOptionality() == Optionality.IGNORED)
-&& aggregateCall.getArgList().size() == 1) {
+if (aggregateCall.isDistinct() && aggregateCall.getArgList().size() == 
1) {
   final int aggIndex = aggregateCall.getArgList().get(0);
   final int newIndex = targetGroupByIndexList.indexOf(aggIndex);
   if (newIndex >= 0) {
 aggregateCalls.add(
-AggregateCall.create(aggregation,
+AggregateCall.create(aggregateCall.getAggregation(),
 aggregateCall.isDistinct(), aggregateCall.isApproximate(),
 aggregateCall.ignoreNulls(),
 ImmutableList.of(newIndex), -1, aggregateCall.distinctKeys,
@@ -1960,7 +1956,7 @@ public class SubstitutionVisitor {
 }
 // When an SqlAggFunction does not support roll up, it will return 
null, which means that
 // it cannot do secondary aggregation and the materialization 
recognition will fail.
-final SqlAggFunction aggFunction = aggregation.getRollup();
+final SqlAggFunction aggFunction = 
aggregateCall.getAggregation().getRollup();
 if (aggFunction == null) {
   return null;
 }
diff --git 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
index 4f54ed8..dede0a7 100644
--- 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
+++ 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
@@ -1659,47 +1659,6 @@ public class MaterializedViewSubstitutionVisitorTest 
extends AbstractMaterialize
 sql(mv, query).ok();
   }
 
-  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroupBy1() {
-final String mv = ""
-+ "select \"name\", \"deptno\" "
-+ "from \"emps\" group by \"name\", \"deptno\"";
-final String query = ""
-+ "select \"name\", min(\"deptno\")\n"
-+ "from \"emps\" group by \"name\"";
-sql(mv, query).ok();
-  }
-
-  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroupBy2() {
-final String mv = ""
-+ "select \"name\", \"commission\", \"deptno\"\n"
-+ "from \"emps\" group by \"name\", \"commission\", \"deptno\"";
-final String query = ""
-+ "select \"name\", \"commission\", max(\"deptno\") as cnt\n"
-+ "from \"emps\" group by \"name\", \"commission\"";
-sql(mv, query).ok();
-  }
-
-  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroup

[calcite] branch master updated: [CALCITE-4817] Expand SubstitutionVisitor of Aggregate with max/min, which column is the group by list of target (xurenhe)

2021-10-05 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 74e9778  [CALCITE-4817] Expand SubstitutionVisitor of Aggregate with 
max/min, which column is the group by list of target (xurenhe)
74e9778 is described below

commit 74e97780add051cb71a122075e5bcbceb40e889c
Author: xurenhe 
AuthorDate: Fri Oct 1 17:18:19 2021 +0800

[CALCITE-4817] Expand SubstitutionVisitor of Aggregate with max/min, which 
column is the group by list of target (xurenhe)

Close #2556
---
 .../apache/calcite/plan/SubstitutionVisitor.java   | 10 --
 .../MaterializedViewSubstitutionVisitorTest.java   | 41 ++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java 
b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
index c0899fa..25423b4 100644
--- a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
+++ b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
@@ -61,6 +61,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
 import org.apache.calcite.util.ControlFlowException;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Litmus;
+import org.apache.calcite.util.Optionality;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 import org.apache.calcite.util.mapping.Mapping;
@@ -1935,12 +1936,15 @@ public class SubstitutionVisitor {
   }
   final List aggregateCalls = new ArrayList<>();
   for (AggregateCall aggregateCall : query.aggCalls) {
-if (aggregateCall.isDistinct() && aggregateCall.getArgList().size() == 
1) {
+final SqlAggFunction aggregation = aggregateCall.getAggregation();
+if ((aggregateCall.isDistinct()
+|| aggregation.getDistinctOptionality() == Optionality.IGNORED)
+&& aggregateCall.getArgList().size() == 1) {
   final int aggIndex = aggregateCall.getArgList().get(0);
   final int newIndex = targetGroupByIndexList.indexOf(aggIndex);
   if (newIndex >= 0) {
 aggregateCalls.add(
-AggregateCall.create(aggregateCall.getAggregation(),
+AggregateCall.create(aggregation,
 aggregateCall.isDistinct(), aggregateCall.isApproximate(),
 aggregateCall.ignoreNulls(),
 ImmutableList.of(newIndex), -1, aggregateCall.distinctKeys,
@@ -1956,7 +1960,7 @@ public class SubstitutionVisitor {
 }
 // When an SqlAggFunction does not support roll up, it will return 
null, which means that
 // it cannot do secondary aggregation and the materialization 
recognition will fail.
-final SqlAggFunction aggFunction = 
aggregateCall.getAggregation().getRollup();
+final SqlAggFunction aggFunction = aggregation.getRollup();
 if (aggFunction == null) {
   return null;
 }
diff --git 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
index dede0a7..4f54ed8 100644
--- 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
+++ 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
@@ -1659,6 +1659,47 @@ public class MaterializedViewSubstitutionVisitorTest 
extends AbstractMaterialize
 sql(mv, query).ok();
   }
 
+  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroupBy1() {
+final String mv = ""
++ "select \"name\", \"deptno\" "
++ "from \"emps\" group by \"name\", \"deptno\"";
+final String query = ""
++ "select \"name\", min(\"deptno\")\n"
++ "from \"emps\" group by \"name\"";
+sql(mv, query).ok();
+  }
+
+  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroupBy2() {
+final String mv = ""
++ "select \"name\", \"commission\", \"deptno\"\n"
++ "from \"emps\" group by \"name\", \"commission\", \"deptno\"";
+final String query = ""
++ "select \"name\", \"commission\", max(\"deptno\") as cnt\n"
++ "from \"emps\" group by \"name\", \"commission\"";
+sql(mv, query).ok();
+  }
+
+  @Test void testQueryNoDistinctOptionalityAggCallColInTargetGroupBy3() {
+final String mv = ""
+   

[calcite] branch master updated: [CALCITE-4177] RelJson should throw if asked to deserialize a call to an unknown operator (Xzh & Wang Yanlin)

2021-09-20 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 ce86af8  [CALCITE-4177] RelJson should throw if asked to deserialize a 
call to an unknown operator (Xzh & Wang Yanlin)
ce86af8 is described below

commit ce86af83caae335d1b47def55354d42a517f45d0
Author: xzh <953396...@qq.com>
AuthorDate: Tue Sep 14 20:32:36 2021 +0800

[CALCITE-4177] RelJson should throw if asked to deserialize a call to an 
unknown operator (Xzh & Wang Yanlin)

Close #2520
---
 .../apache/calcite/rel/externalize/RelJson.java|  3 ++-
 .../apache/calcite/runtime/CalciteResource.java|  4 
 .../calcite/runtime/CalciteResource.properties |  1 +
 .../org/apache/calcite/plan/RelWriterTest.java | 27 ++
 4 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java 
b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
index 88f9d99..6250240 100644
--- a/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
+++ b/core/src/main/java/org/apache/calcite/rel/externalize/RelJson.java
@@ -78,6 +78,7 @@ import java.util.Map;
 import java.util.Set;
 
 import static org.apache.calcite.rel.RelDistributions.EMPTY;
+import static org.apache.calcite.util.Static.RESOURCE;
 
 import static java.util.Objects.requireNonNull;
 
@@ -743,7 +744,7 @@ public class RelJson {
 if (class_ != null) {
   return AvaticaUtils.instantiatePlugin(SqlOperator.class, class_);
 }
-return null;
+throw RESOURCE.noOperator(name, kind, syntax).ex();
   }
 
   @Nullable SqlAggFunction toAggregation(Map map) {
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java 
b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index ec38767..7f9d54f 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -967,4 +967,8 @@ public interface CalciteResource {
 
   @BaseMessage("Different length for bitwise operands: the first: 
{0,number,#}, the second: {1,number,#}")
   ExInst differentLengthForBitwiseOperands(int l0, int l1);
+
+  @BaseMessage("No operator for ''{0}'' with kind: ''{1}'', syntax: ''{2}'' 
during JSON deserialization")
+  ExInst noOperator(String name, String kind, String syntax);
+
 }
diff --git 
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties 
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
index 85768e7..c166ab4 100644
--- 
a/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
+++ 
b/core/src/main/resources/org/apache/calcite/runtime/CalciteResource.properties
@@ -316,4 +316,5 @@ InvalidInputForExtractValue=Invalid input for EXTRACTVALUE: 
xml: ''{0}'', xpath
 InvalidInputForExtractXml=Invalid input for EXTRACT xpath: ''{0}'', namespace: 
''{1}''
 InvalidInputForExistsNode=Invalid input for EXISTSNODE xpath: ''{0}'', 
namespace: ''{1}''
 DifferentLengthForBitwiseOperands=Different length for bitwise operands: the 
first: {0,number,#}, the second: {1,number,#}
+NoOperator=No operator for ''{0}'' with kind: ''{1}'', syntax: ''{2}'' during 
JSON deserialization
 # End CalciteResource.properties
diff --git a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java 
b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
index c0720a2..13330d6 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
@@ -85,6 +85,7 @@ import static org.apache.calcite.test.Matchers.isLinux;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * Unit test for {@link org.apache.calcite.rel.externalize.RelJson}.
@@ -692,6 +693,32 @@ class RelWriterTest {
 assertThat(s, isLinux(expected));
   }
 
+  @Test void testDeserializeInvalidOperatorName() {
+final FrameworkConfig config = RelBuilderTest.config().build();
+final RelBuilder builder = RelBuilder.create(config);
+final RelNode rel = builder
+.scan("EMP")
+.project(
+builder.field("JOB"),
+builder.field("SAL"))
+.aggregate(
+builder.groupKey("JOB"),
+builder.max("max_sal", builder.field("SAL")),
+builder.min("min_sal", builder.field("SAL")))
+.project(
+builder.field("max_sal"),
+builder.field("min_sal"))
+.build();
+final RelJsonWriter jsonWriter = new RelJsonWriter();
+

[calcite] branch master updated: [CALCITE-4774] Materialized view recognition fails for equivalent predicates (dz)

2021-09-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 60457b2  [CALCITE-4774] Materialized view recognition fails for 
equivalent predicates (dz)
60457b2 is described below

commit 60457b28c890f12cc811528bd4f3b098bc3d00f7
Author: dz <953396...@qq.com>
AuthorDate: Tue Sep 14 15:59:34 2021 +0800

[CALCITE-4774] Materialized view recognition fails for equivalent 
predicates (dz)

Close #2514
---
 .../apache/calcite/plan/SubstitutionVisitor.java   |  2 ++
 .../MaterializedViewSubstitutionVisitorTest.java   | 32 ++
 2 files changed, 34 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java 
b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
index 1ad33f2..e0f78b0 100644
--- a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
+++ b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
@@ -285,6 +285,8 @@ public class SubstitutionVisitor {
   public static @Nullable RexNode splitFilter(final RexSimplify simplify,
   RexNode condition, RexNode target) {
 final RexBuilder rexBuilder = simplify.rexBuilder;
+condition = simplify.simplify(condition);
+target = simplify.simplify(target);
 RexNode condition2 = canonizeNode(rexBuilder, condition);
 RexNode target2 = canonizeNode(rexBuilder, target);
 
diff --git 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
index f5f71f5..bed699f 100644
--- 
a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
+++ 
b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
@@ -1575,6 +1575,38 @@ public class MaterializedViewSubstitutionVisitorTest 
extends AbstractMaterialize
 sql(mv, query).ok();
   }
 
+  @Test void testRexPredicate() {
+final String mv = ""
++ "select \"name\"\n"
++ "from \"emps\"\n"
++ "where \"deptno\" > 100 and \"deptno\" > 50\n"
++ "group by \"name\"";
+final String query = ""
++ "select \"name\"\n"
++ "from \"emps\"\n"
++ "where \"deptno\" > 100"
++ "group by \"name\"";
+sql(mv, query).withChecker(
+resultContains(""
++ "EnumerableTableScan(table=[[hr, MV0]])")).ok();
+  }
+
+  @Test void testRexPredicate1() {
+final String query = ""
++ "select \"name\"\n"
++ "from \"emps\"\n"
++ "where \"deptno\" > 100 and \"deptno\" > 50\n"
++ "group by \"name\"";
+final String mv = ""
++ "select \"name\"\n"
++ "from \"emps\"\n"
++ "where \"deptno\" > 100"
++ "group by \"name\"";
+sql(mv, query).withChecker(
+resultContains(""
++ "EnumerableTableScan(table=[[hr, MV0]])")).ok();
+  }
+
   final JavaTypeFactoryImpl typeFactory =
   new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
   private final RexBuilder rexBuilder = new RexBuilder(typeFactory);


[calcite] branch master updated: [CALCITE-4652] AggregateExpandDistinctAggregatesRule must cast top aggregates to original type (Taras Ledkov)

2021-08-12 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 8a1535f  [CALCITE-4652] AggregateExpandDistinctAggregatesRule must 
cast top aggregates to original type (Taras Ledkov)
8a1535f is described below

commit 8a1535f94aad1e0ce77797eb84d75b4a5b1692c1
Author: tledkov 
AuthorDate: Fri Jun 4 17:54:17 2021 +0300

[CALCITE-4652] AggregateExpandDistinctAggregatesRule must cast top 
aggregates to original type (Taras Ledkov)

Close #2439
---
 .../AggregateExpandDistinctAggregatesRule.java | 12 -
 .../org/apache/calcite/test/RelOptRulesTest.java   | 44 
 .../org/apache/calcite/test/SqlToRelTestBase.java  | 58 +-
 .../org/apache/calcite/test/RelOptRulesTest.xml| 21 
 4 files changed, 111 insertions(+), 24 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
 
b/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
index 6ef9dae..cec3e58 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/AggregateExpandDistinctAggregatesRule.java
@@ -26,6 +26,7 @@ import org.apache.calcite.rel.core.AggregateCall;
 import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.RelFactories;
 import org.apache.calcite.rel.logical.LogicalAggregate;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexInputRef;
@@ -366,12 +367,15 @@ public final class AggregateExpandDistinctAggregatesRule
 final int arg = bottomGroups.size() + nonDistinctAggCallProcessedSoFar;
 final List newArgs = ImmutableList.of(arg);
 if (aggCall.getAggregation().getKind() == SqlKind.COUNT) {
+  RelDataTypeFactory typeFactory = 
aggregate.getCluster().getTypeFactory();
+
   newCall =
   AggregateCall.create(new SqlSumEmptyIsZeroAggFunction(), false,
   aggCall.isApproximate(), aggCall.ignoreNulls(),
   newArgs, -1, aggCall.distinctKeys, aggCall.collation,
   originalGroupSet.cardinality(), relBuilder.peek(),
-  aggCall.getType(), aggCall.getName());
+  typeFactory.getTypeSystem().deriveSumType(typeFactory, 
aggCall.getType()),
+  aggCall.getName());
 } else {
   newCall =
   AggregateCall.create(aggCall.getAggregation(), false,
@@ -400,6 +404,12 @@ public final class AggregateExpandDistinctAggregatesRule
 relBuilder.push(
 aggregate.copy(aggregate.getTraitSet(), relBuilder.build(),
 ImmutableBitSet.of(topGroupSet), null, topAggregateCalls));
+
+// Add projection node for case: SUM of COUNT(*):
+// Type of the SUM may be larger than type of COUNT.
+// CAST to original type must be added.
+relBuilder.convert(aggregate.getRowType(), true);
+
 return relBuilder;
   }
 
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java 
b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index d2b53c1..809289b 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -89,6 +89,7 @@ import org.apache.calcite.rel.rules.UnionMergeRule;
 import org.apache.calcite.rel.rules.ValuesReduceRule;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeSystemImpl;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexInputRef;
@@ -107,6 +108,7 @@ import org.apache.calcite.sql.fun.SqlLibrary;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.type.OperandTypes;
 import org.apache.calcite.sql.type.ReturnTypes;
+import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
@@ -136,6 +138,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.function.Supplier;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -6769,4 +6772,45 @@ class RelOptRulesTest extends RelOptTestBase {
   relFn(relFn).with(hepPlanner).checkUnchanged();
 }
   }
+
+  /**
+   * Test case for https://issues.apache.org/jira/browse/CALCITE-4652

[calcite] branch master updated: [CALCITE-4638] VolcanoPlanner fails to recognize transformation rule correctly in the top-down mode (Vladimir Ozerov)

2021-07-06 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 40baa00  [CALCITE-4638] VolcanoPlanner fails to recognize 
transformation rule correctly in the top-down mode (Vladimir Ozerov)
40baa00 is described below

commit 40baa0056980ddbd4fcd4e957f59d3b12d86e739
Author: Vladimir Ozerov 
AuthorDate: Sun Jun 13 20:18:32 2021 +0300

[CALCITE-4638] VolcanoPlanner fails to recognize transformation rule 
correctly in the top-down mode (Vladimir Ozerov)
---
 .../org/apache/calcite/plan/volcano/VolcanoPlanner.java  | 10 +-
 .../resources/org/apache/calcite/test/TopDownOptTest.xml | 16 
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
index 14caf5a..3648cd0 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
@@ -1553,15 +1553,7 @@ public class VolcanoPlanner extends 
AbstractRelOptPlanner {
*/
   @API(since = "1.24", status = API.Status.EXPERIMENTAL)
   protected boolean isTransformationRule(VolcanoRuleCall match) {
-if (match.getRule() instanceof SubstitutionRule) {
-  return true;
-}
-if (match.getRule() instanceof ConverterRule
-&& match.getRule().getOutTrait() == rootConvention) {
-  return false;
-}
-return match.getRule().getOperand().trait == Convention.NONE
-|| match.getRule().getOperand().trait == null;
+return match.getRule() instanceof TransformationRule;
   }
 
 
diff --git a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml 
b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
index a8315af..a2eba17 100644
--- a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
@@ -896,8 +896,8 @@ LogicalProject(ENAME=[$0], JOB=[$1], EXPR$2=[$2], 
ENAME0=[$3], JOB0=[$4], SAL=[$
   

[calcite] branch master updated (3957f2a -> fcca914)

2020-10-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 3957f2a  Exclude root project from javadoc aggregate tasks
 add fcca914  Doc: typo fix

No new revisions were added by this update.

Summary of changes:
 site/_docs/geode_adapter.md  |  4 ++--
 site/_docs/howto.md  | 18 +-
 site/_docs/kafka_adapter.md  |  4 ++--
 site/_docs/lattice.md|  4 ++--
 site/_docs/materialized_views.md |  4 ++--
 site/_docs/model.md  |  2 +-
 6 files changed, 18 insertions(+), 18 deletions(-)



[calcite] branch master updated: [CALCITE-3782] Bitwise functions BIT_AND, BIT_OR and BIT_XOR support binary and varbinary type (Hailong Wang)

2020-08-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 9cf829b  [CALCITE-3782] Bitwise functions BIT_AND, BIT_OR and BIT_XOR 
support binary and varbinary type (Hailong Wang)
9cf829b is described below

commit 9cf829bc28113ba01f3ee0c826b502143478680e
Author: wangxlong <18868816...@163.com>
AuthorDate: Fri Mar 27 16:24:56 2020 +0800

[CALCITE-3782] Bitwise functions BIT_AND, BIT_OR and BIT_XOR support binary 
and varbinary type (Hailong Wang)

Close #1878
---
 .../calcite/adapter/enumerable/RexImpTable.java| 10 +++-
 .../apache/calcite/runtime/CalciteResource.java|  3 ++
 .../org/apache/calcite/runtime/SqlFunctions.java   | 55 +++---
 .../calcite/sql/fun/SqlBitOpAggFunction.java   | 19 ++--
 .../calcite/runtime/CalciteResource.properties |  1 +
 .../apache/calcite/sql/test/AbstractSqlTester.java | 16 +++
 .../calcite/sql/test/SqlOperatorBaseTest.java  | 47 --
 .../apache/calcite/sql/test/SqlRuntimeTester.java  | 10 
 .../org/apache/calcite/sql/test/SqlTester.java | 14 ++
 site/_docs/reference.md|  6 +--
 10 files changed, 162 insertions(+), 19 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 20a86a3..176ed1a 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -17,6 +17,7 @@
 package org.apache.calcite.adapter.enumerable;
 
 import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.util.ByteString;
 import org.apache.calcite.avatica.util.DateTimeUtils;
 import org.apache.calcite.avatica.util.TimeUnit;
 import org.apache.calcite.avatica.util.TimeUnitRange;
@@ -1231,8 +1232,13 @@ public class RexImpTable {
   static class BitOpImplementor extends StrictAggImplementor {
 @Override protected void implementNotNullReset(AggContext info,
 AggResetContext reset) {
-  Object initValue = info.aggregation() == BIT_AND ? -1 : 0;
-  Expression start = Expressions.constant(initValue, info.returnType());
+  Expression start;
+  if (SqlTypeUtil.isBinary(info.returnRelType())) {
+start = Expressions.field(null, ByteString.class, "EMPTY");
+  } else {
+Object initValue = info.aggregation() == BIT_AND ? -1L : 0;
+start = Expressions.constant(initValue, info.returnType());
+  }
 
   reset.currentBlock().add(
   Expressions.statement(
diff --git a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java 
b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
index 3aaec91..fa13471 100644
--- a/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
+++ b/core/src/main/java/org/apache/calcite/runtime/CalciteResource.java
@@ -928,4 +928,7 @@ public interface CalciteResource {
 
   @BaseMessage("Invalid input for EXTRACTVALUE: xml: ''{0}'', xpath 
expression: ''{1}''")
   ExInst invalidInputForExtractValue(String xml, String 
xpath);
+
+  @BaseMessage("Different length for bitwise operands: the first: 
{0,number,#}, the second: {1,number,#}")
+  ExInst differentLengthForBitwiseOperands(int l0, int l1);
 }
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java 
b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 608af6f..2c55290 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -73,6 +73,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.TimeZone;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.BinaryOperator;
 import java.util.regex.Pattern;
 import javax.annotation.Nonnull;
 
@@ -1109,24 +1110,66 @@ public class SqlFunctions {
 op, b1.getClass().toString()).ex();
   }
 
-  // &
-  /** Helper function for implementing BIT_AND. */
+  /** Bitwise function BIT_AND applied to integer values. */
   public static long bitAnd(long b0, long b1) {
 return b0 & b1;
   }
 
-  // |
-  /** Helper function for implementing BIT_OR. */
+  /** Bitwise function BIT_AND applied to binary values. */
+  public static ByteString bitAnd(ByteString b0, ByteString b1) {
+return binaryOperator(b0, b1, (x, y) -> (byte) (x & y));
+  }
+
+  /** Bitwise function BIT_OR applied to integer values. */
   public static long bitOr(long b0, long b1) {
 return b0 | b1;
   }
 
-  // ^
-  /** Helper function for implementing BIT_XOR. */
+  /** Bitwise function BIT_OR applied to binary values. */
+  public static ByteStrin

[calcite] branch master updated: Add assertion that relnode after pass through traits has the same convention

2020-08-19 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 6968f0a  Add assertion that relnode after pass through traits has the 
same convention
6968f0a is described below

commit 6968f0af4aa4d0ec6cdc86dfb8372fe8652de7b9
Author: Haisheng Yuan 
AuthorDate: Wed Aug 19 15:04:23 2020 -0500

Add assertion that relnode after pass through traits has the same convention

Change-Id: I5dbb39899809055340fe14fa1c09bc25835dd5be
---
 .../main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
index d41c624..0115a05 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
@@ -563,13 +563,14 @@ class TopDownRuleDriver implements RuleDriver {
 return new OptimizeInputs(rel, group);
   }
 
-  // Try converting the physical node to another trait sets
-  // either by converter rule or traits pass though.
+  // Try to convert the physical node to another trait sets,
+  // either by converter rule or traits pass through.
   private RelNode convert(RelNode rel, RelSubset group) {
 if (!passThroughCache.contains(rel)) {
   if (checkLowerBound(rel, group)) {
 RelNode passThrough = group.passThrough(rel);
 if (passThrough != null) {
+  assert passThrough.getConvention() == rel.getConvention();
   passThroughCache.add(passThrough);
   return passThrough;
 }



[calcite] branch master updated: [CALCITE-4102] Some improvements to aggregate related operations (Liya Fan)

2020-07-29 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 ce2ae64  [CALCITE-4102] Some improvements to aggregate related 
operations (Liya Fan)
ce2ae64 is described below

commit ce2ae649c9ec072ceb8462b2783f8c6bba989241
Author: liyafan82 
AuthorDate: Thu Jul 2 12:38:25 2020 +0800

[CALCITE-4102] Some improvements to aggregate related operations (Liya Fan)

1. Extract a common method for ImmutableBitSet
2. Refine the use of data structures
3. Replace expensive operations with cheap ones
---
 .../org/apache/calcite/rel/core/Aggregate.java | 25 --
 .../sql/validate/AggregatingSelectScope.java   | 11 +-
 .../org/apache/calcite/util/ImmutableBitSet.java   | 13 +++
 .../main/java/org/apache/calcite/util/Util.java|  1 +
 .../apache/calcite/util/ImmutableBitSetTest.java   | 20 +
 5 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java 
b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
index e8a4b73..634e0fb 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java
@@ -51,8 +51,8 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.math.IntMath;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
@@ -393,7 +393,7 @@ public abstract class Aggregate extends SingleRel 
implements Hintable {
   final RelDataTypeField field = fieldList.get(groupKey);
   containedNames.add(field.getName());
   builder.add(field);
-  if (groupSets != null && !allContain(groupSets, groupKey)) {
+  if (groupSets != null && !ImmutableBitSet.allContain(groupSets, 
groupKey)) {
 builder.nullable(true);
   }
 }
@@ -416,16 +416,6 @@ public abstract class Aggregate extends SingleRel 
implements Hintable {
 return builder.build();
   }
 
-  private static boolean allContain(List groupSets,
-  int groupKey) {
-for (ImmutableBitSet groupSet : groupSets) {
-  if (!groupSet.get(groupKey)) {
-return false;
-  }
-}
-return true;
-  }
-
   public boolean isValid(Litmus litmus, Context context) {
 return super.isValid(litmus, context)
 && litmus.check(Util.isDistinct(getRowType().getFieldNames()),
@@ -529,7 +519,7 @@ public abstract class Aggregate extends SingleRel 
implements Hintable {
   // Each subsequent items must be a subset with one fewer bit than the
   // previous item
   if (!g.contains(bitSet)
-  || g.except(bitSet).cardinality() != 1) {
+  || g.cardinality() - bitSet.cardinality() != 1) {
 return false;
   }
 }
@@ -548,7 +538,7 @@ public abstract class Aggregate extends SingleRel 
implements Hintable {
  *
  * @see #isRollup(ImmutableBitSet, List) */
 public static List getRollup(List groupSets) {
-  final Set set = new LinkedHashSet<>();
+  final List rollUpBits = new ArrayList<>(groupSets.size() - 1);
   ImmutableBitSet g = null;
   for (ImmutableBitSet bitSet : groupSets) {
 if (g == null) {
@@ -556,11 +546,14 @@ public abstract class Aggregate extends SingleRel 
implements Hintable {
 } else {
   // Each subsequent items must be a subset with one fewer bit than the
   // previous item
-  set.addAll(g.except(bitSet).toList());
+  ImmutableBitSet diff = g.except(bitSet);
+  assert diff.cardinality() == 1;
+  rollUpBits.add(diff.nth(0));
 }
 g = bitSet;
   }
-  return ImmutableList.copyOf(set).reverse();
+  Collections.reverse(rollUpBits);
+  return ImmutableList.copyOf(rollUpBits);
 }
   }
 
diff --git 
a/core/src/main/java/org/apache/calcite/sql/validate/AggregatingSelectScope.java
 
b/core/src/main/java/org/apache/calcite/sql/validate/AggregatingSelectScope.java
index e0e9b3c..415a21f 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/validate/AggregatingSelectScope.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/validate/AggregatingSelectScope.java
@@ -166,15 +166,6 @@ public class AggregatingSelectScope
 return select;
   }
 
-  private static boolean allContain(List bitSets, int bit) {
-for (ImmutableBitSet bitSet : bitSets) {
-  if (!bitSet.get(bit)) {
-return false;
-  }
-}
-return true;
-  }
-
   @Override public RelDataType nullifyType(SqlNode node, RelDataType type) {
 final Resolved r = this.resolved.get();
 for (Ord groupExpr : Ord.zip(r.groupExprList)

[calcite] branch master updated (61e6ac1 -> b306668)

2020-07-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


omit 61e6ac1  Remove useless method appendRelDescription

This update removed existing revisions from the reference, leaving the
reference pointing at a previous point in the repository history.

 * -- * -- N   refs/heads/master (b306668)
\
 O -- O -- O   (61e6ac1)

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

No new revisions were added by this update.

Summary of changes:
 core/src/main/java/org/apache/calcite/plan/RelOptUtil.java | 8 
 1 file changed, 8 insertions(+)



[calcite] branch master updated: Remove useless method appendRelDescription

2020-07-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 61e6ac1  Remove useless method appendRelDescription
61e6ac1 is described below

commit 61e6ac12a3e97d316ac8a77afd7cc93da469adc0
Author: Haisheng Yuan 
AuthorDate: Mon Jul 27 20:01:24 2020 -0500

Remove useless method appendRelDescription
---
 core/src/main/java/org/apache/calcite/plan/RelOptUtil.java | 8 
 1 file changed, 8 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index 2e634f8..0f2ff5f 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -2063,14 +2063,6 @@ public abstract class RelOptUtil {
 
   }
 
-  @Deprecated // to be removed before 1.25
-  public static StringBuilder appendRelDescription(
-  StringBuilder sb, RelNode rel) {
-sb.append("rel#").append(rel.getId())
-.append(':').append(rel.getDigest());
-return sb;
-  }
-
   /**
* Dumps a plan as a string.
*



[calcite] branch master updated: Remove useless method appendRelDescription

2020-07-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 61e6ac1  Remove useless method appendRelDescription
61e6ac1 is described below

commit 61e6ac12a3e97d316ac8a77afd7cc93da469adc0
Author: Haisheng Yuan 
AuthorDate: Mon Jul 27 20:01:24 2020 -0500

Remove useless method appendRelDescription
---
 core/src/main/java/org/apache/calcite/plan/RelOptUtil.java | 8 
 1 file changed, 8 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
index 2e634f8..0f2ff5f 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptUtil.java
@@ -2063,14 +2063,6 @@ public abstract class RelOptUtil {
 
   }
 
-  @Deprecated // to be removed before 1.25
-  public static StringBuilder appendRelDescription(
-  StringBuilder sb, RelNode rel) {
-sb.append("rel#").append(rel.getId())
-.append(':').append(rel.getDigest());
-return sb;
-  }
-
   /**
* Dumps a plan as a string.
*



[calcite] branch master updated: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 4625280  [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao 
Tao)
4625280 is described below

commit 462528077d64d47cef781c2d54ab4484dad76dde
Author: Jiatao Tao <245915...@qq.com>
AuthorDate: Sun Jul 19 17:17:55 2020 +0800

[CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Close #2076
---
 .../ChainedPhaseRuleMappingInitializer.java|  68 ---
 .../calcite/plan/volcano/IterativeRuleDriver.java  |  45 +++
 .../calcite/plan/volcano/IterativeRuleQueue.java   | 135 +
 .../calcite/plan/volcano/VolcanoPlanner.java   |  10 --
 .../calcite/plan/volcano/VolcanoPlannerPhase.java  |  26 
 .../VolcanoPlannerPhaseRuleMappingInitializer.java |  49 
 .../calcite/plan/volcano/VolcanoPlannerTest.java   |   2 +-
 7 files changed, 48 insertions(+), 287 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/ChainedPhaseRuleMappingInitializer.java
 
b/core/src/main/java/org/apache/calcite/plan/volcano/ChainedPhaseRuleMappingInitializer.java
deleted file mode 100644
index ce276c1..000
--- 
a/core/src/main/java/org/apache/calcite/plan/volcano/ChainedPhaseRuleMappingInitializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.plan.volcano;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * ChainedPhaseRuleMappingInitializer is an abstract implementation of
- * {@link VolcanoPlannerPhaseRuleMappingInitializer} that allows additional
- * rules to be layered on top of those configured by a subordinate
- * {@link VolcanoPlannerPhaseRuleMappingInitializer}.
- *
- * @see VolcanoPlannerPhaseRuleMappingInitializer
- */
-public abstract class ChainedPhaseRuleMappingInitializer
-implements VolcanoPlannerPhaseRuleMappingInitializer {
-  //~ Instance fields 
-
-  private final VolcanoPlannerPhaseRuleMappingInitializer subordinate;
-
-  //~ Constructors ---
-
-  public ChainedPhaseRuleMappingInitializer(
-  VolcanoPlannerPhaseRuleMappingInitializer subordinate) {
-this.subordinate = subordinate;
-  }
-
-  //~ Methods 
-
-  public final void initialize(
-  Map> phaseRuleMap) {
-// Initialize subordinate's mappings.
-subordinate.initialize(phaseRuleMap);
-
-// Initialize our mappings.
-chainedInitialize(phaseRuleMap);
-  }
-
-  /**
-   * Extend this method to provide phase-to-rule mappings beyond what is
-   * provided by this initializer's subordinate.
-   *
-   * When this method is called, the map will already be pre-initialized
-   * with empty sets for each VolcanoPlannerPhase. Implementations must not
-   * return having added or removed keys from the map, although it is safe to
-   * temporarily add or remove keys.
-   *
-   * @param phaseRuleMap the {@link VolcanoPlannerPhase}-rule description map
-   * @see VolcanoPlannerPhaseRuleMappingInitializer
-   */
-  public abstract void chainedInitialize(
-  Map> phaseRuleMap);
-}
diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
index 3ff8300..3883e48 100644
--- 
a/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
+++ 
b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
@@ -22,11 +22,10 @@ import org.apache.calcite.util.trace.CalciteTrace;
 import org.slf4j.Logger;
 
 /***
- * The algorithm executes repeatedly in a series of phases. In each phase
- * the exact rules that may be fired varies. The mapping of phases to rule
- * sets is maintained in the {@link #ruleQueue}.
+ * The algorithm executes repeatedly. The exact rules
+ * that may be fired varies.
  *
- * In each phase, the planner the

[calcite] branch master updated (af89226 -> 27c067a)

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


omit af89226  Add back API annotation in AbstractRelNode
 new 27c067a  Add back API annotation in AbstractRelNode

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (af89226)
\
 N -- N -- N   refs/heads/master (27c067a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



[calcite] 01/01: Add back API annotation in AbstractRelNode

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 27c067a983cf4c71d46c6ee49608151912662f88
Author: Haisheng Yuan 
AuthorDate: Sun Jul 26 09:35:02 2020 -0500

Add back API annotation in AbstractRelNode
---
 core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java 
b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index 3f2aa28..f6c2987 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -406,6 +406,7 @@ public abstract class AbstractRelNode implements RelNode {
* @return Whether the 2 RelNodes are equivalent or have the same digest.
* @see #deepHashCode()
*/
+  @API(since = "1.25", status = API.Status.MAINTAINED)
   public boolean deepEquals(Object obj) {
 if (this == obj) {
   return true;
@@ -441,6 +442,7 @@ public abstract class AbstractRelNode implements RelNode {
*
* @see #deepEquals(Object)
*/
+  @API(since = "1.25", status = API.Status.MAINTAINED)
   public int deepHashCode() {
 int result = 31 + getTraitSet().hashCode();
 List> items = this.getDigestItems();



[calcite] branch master updated: Add back API annotation in AbstractRelNode

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 af89226  Add back API annotation in AbstractRelNode
af89226 is described below

commit af8922676925b1d7ebee8479fa6ef8114c22074a
Author: Haisheng Yuan 
AuthorDate: Sun Jul 26 09:35:02 2020 -0500

Add back API annotation in AbstractRelNode
---
 core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java 
b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index 3f2aa28..7d599db 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -406,6 +406,7 @@ public abstract class AbstractRelNode implements RelNode {
* @return Whether the 2 RelNodes are equivalent or have the same digest.
* @see #deepHashCode()
*/
+  @API(since = "1.24", status = API.Status.MAINTAINED)
   public boolean deepEquals(Object obj) {
 if (this == obj) {
   return true;
@@ -441,6 +442,7 @@ public abstract class AbstractRelNode implements RelNode {
*
* @see #deepEquals(Object)
*/
+  @API(since = "1.24", status = API.Status.MAINTAINED)
   public int deepHashCode() {
 int result = 31 + getTraitSet().hashCode();
 List> items = this.getDigestItems();



[calcite] branch master updated (0fdf185 -> b7e2454)

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 0fdf185  [CALCITE-4141] Make checkstyle tasks relocatable to support 
Gradle build cache
 add b7e2454  [CALCITE-4129] Support deep equality check for RelNode

No new revisions were added by this update.

Summary of changes:
 .../org/apache/calcite/plan/hep/HepRelVertex.java  |  4 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  4 +-
 .../org/apache/calcite/rel/AbstractRelNode.java| 73 +++---
 .../main/java/org/apache/calcite/rel/RelNode.java  | 21 +++
 .../java/org/apache/calcite/rel/core/Filter.java   |  8 +--
 .../java/org/apache/calcite/rel/core/Join.java | 10 +--
 .../java/org/apache/calcite/rel/core/Project.java  |  8 +--
 .../apache/calcite/rel/logical/LogicalFilter.java  |  8 +--
 .../apache/calcite/rel/logical/LogicalJoin.java|  8 +--
 .../apache/calcite/rel/logical/LogicalProject.java |  8 +--
 .../java/org/apache/calcite/rex/RexSubQuery.java   | 16 +++--
 .../rel/logical/ToLogicalConverterTest.java| 27 
 12 files changed, 139 insertions(+), 56 deletions(-)



[calcite] branch master updated (0fdf185 -> b7e2454)

2020-07-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 0fdf185  [CALCITE-4141] Make checkstyle tasks relocatable to support 
Gradle build cache
 add b7e2454  [CALCITE-4129] Support deep equality check for RelNode

No new revisions were added by this update.

Summary of changes:
 .../org/apache/calcite/plan/hep/HepRelVertex.java  |  4 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  4 +-
 .../org/apache/calcite/rel/AbstractRelNode.java| 73 +++---
 .../main/java/org/apache/calcite/rel/RelNode.java  | 21 +++
 .../java/org/apache/calcite/rel/core/Filter.java   |  8 +--
 .../java/org/apache/calcite/rel/core/Join.java | 10 +--
 .../java/org/apache/calcite/rel/core/Project.java  |  8 +--
 .../apache/calcite/rel/logical/LogicalFilter.java  |  8 +--
 .../apache/calcite/rel/logical/LogicalJoin.java|  8 +--
 .../apache/calcite/rel/logical/LogicalProject.java |  8 +--
 .../java/org/apache/calcite/rex/RexSubQuery.java   | 16 +++--
 .../rel/logical/ToLogicalConverterTest.java| 27 
 12 files changed, 139 insertions(+), 56 deletions(-)



svn commit: r40661 - /release/calcite/apache-calcite-1.22.0/

2020-07-23 Thread hyuan
Author: hyuan
Date: Fri Jul 24 05:18:12 2020
New Revision: 40661

Log:
Remove apache-calcite-1.22.0

Removed:
release/calcite/apache-calcite-1.22.0/



[calcite] annotated tag calcite-1.24.0 updated (4b5b910 -> 9eead5a)

2020-07-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to annotated tag calcite-1.24.0
in repository https://gitbox.apache.org/repos/asf/calcite.git.


*** WARNING: tag calcite-1.24.0 was modified! ***

from 4b5b910  (commit)
  to 9eead5a  (tag)
 tagging 4b5b9100e59ae4a43424156c9beabec6805f3d7c (commit)
 replaces calcite-1.23.0
  by Haisheng Yuan
  on Thu Jul 23 23:34:32 2020 -0500

- Log -
---


No new revisions were added by this update.

Summary of changes:



[calcite] annotated tag calcite-1.24.0 updated (4b5b910 -> 9eead5a)

2020-07-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to annotated tag calcite-1.24.0
in repository https://gitbox.apache.org/repos/asf/calcite.git.


*** WARNING: tag calcite-1.24.0 was modified! ***

from 4b5b910  (commit)
  to 9eead5a  (tag)
 tagging 4b5b9100e59ae4a43424156c9beabec6805f3d7c (commit)
 replaces calcite-1.23.0
  by Haisheng Yuan
  on Thu Jul 23 23:34:32 2020 -0500

- Log -
---


No new revisions were added by this update.

Summary of changes:



svn commit: r40660 - /dev/calcite/apache-calcite-1.24.0-rc0/ /release/calcite/apache-calcite-1.24.0/

2020-07-23 Thread hyuan
Author: hyuan
Date: Fri Jul 24 04:03:05 2020
New Revision: 40660

Log:
Promoting Apache Calcite calcite-1.24.0-rc0 -> calcite-1.24.0 to release area

Added:
release/calcite/apache-calcite-1.24.0/
release/calcite/apache-calcite-1.24.0/apache-calcite-1.24.0-src.tar.gz
  - copied unchanged from r40574, 
dev/calcite/apache-calcite-1.24.0-rc0/apache-calcite-1.24.0-src.tar.gz
release/calcite/apache-calcite-1.24.0/apache-calcite-1.24.0-src.tar.gz.asc
  - copied unchanged from r40574, 
dev/calcite/apache-calcite-1.24.0-rc0/apache-calcite-1.24.0-src.tar.gz.asc

release/calcite/apache-calcite-1.24.0/apache-calcite-1.24.0-src.tar.gz.sha512
  - copied unchanged from r40574, 
dev/calcite/apache-calcite-1.24.0-rc0/apache-calcite-1.24.0-src.tar.gz.sha512
Removed:
dev/calcite/apache-calcite-1.24.0-rc0/



svn commit: r40563 - /release/calcite/KEYS

2020-07-19 Thread hyuan
Author: hyuan
Date: Mon Jul 20 04:43:21 2020
New Revision: 40563

Log:
Add Chunwei's gpg key to KEYS file

Modified:
release/calcite/KEYS

Modified: release/calcite/KEYS
==
--- release/calcite/KEYS (original)
+++ release/calcite/KEYS Mon Jul 20 04:43:21 2020
@@ -1777,3 +1777,62 @@ ipPKWR3S0Vrztlzu17q+bB3PgtAQt1FrSg6UB3XZ
 MIU6EJiQuZs=
 =bRKv
 -END PGP PUBLIC KEY BLOCK-
+pub   rsa4096 2020-07-20 [SC] [expires: 2023-07-20]
+  8B980005AB2322F7C85F13031F1597F99BCE51A1
+uid   [ultimate] chunwei 
+sig 31F1597F99BCE51A1 2020-07-20  chunwei 
+sub   rsa4096 2020-07-20 [E] [expires: 2023-07-20]
+sig  1F1597F99BCE51A1 2020-07-20  chunwei 
+
+-BEGIN PGP PUBLIC KEY BLOCK-
+
+mQINBF8VGIMBEADDQOf9vgJL8fmhI3bAN6ZC4si0Q8HxJrZMr1CQPcQIrVK8E9Ps
+GlHJX1XisVzACXuu5yRX9ZlcgkKnQz1sQr4lCPkk4fjRqjt9d0T8fmK7wetveofz
+fwhaSUYcjov3IQBjNZhWY4Uv7ZlEDnQImw2cNKQyput6MR+C0v9HIHRM/UlCUAL/
+nm1iaWwYumygVwRMlAwOe2DnNm/pr+DPp935C97+ZJwIrm3V7OA8vc5nP8BiEaPO
+ZrW5319OL/Ukt3FruVku5WnfwV8cTd5GMDGf6OexhQ2H1IKA7RMhZmPxsOepauAh
+VGjz1aRvoDkr2x1hK9I/W1z80oSnU9h7iaTzgBRZxTHd04jieokhDgbZVVo22LNK
+sCCey83MzpZl+tS8fe2lEOWWTObIN93O1lGXAelWSDJmq90qEWJ0V5WbfVmozTps
+l8siQXvrnwe44eFwLMNSiHi3Pi+IIrsnD+pWmEqxje5OUlwP2HX0XzzCzL7WoGp5
+bAr2DKHFAg1RvaVD9WdmibOWyRTDKHCSz+w2wwyF2FC6WxTjTLSVUhaAWxHKV7oD
+rdVSf0qamfn53e3koUBzcWLACgbdOPIlRniWmcwFJjAE1yqQvlZ7XQWo/en8WR6s
+enUWKggcRMByU7F6R1WBDYxIZPUiiXrc7z6XHDs5NJRgk0NVJ25BhYr2FwARAQAB
+tBxjaHVud2VpIDxjaHVud2VpQGFwYWNoZS5vcmc+iQJUBBMBCAA+FiEEi5gABasj
+IvfIXxMDHxWX+ZvOUaEFAl8VGIMCGwMFCQWjmoAFCwkIBwIGFQoJCAsCBBYCAwEC
+HgECF4AACgkQHxWX+ZvOUaG09w//XdtB4VAQ3DBS0dfMbskRPe6DhKF42tq3jTtv
+UwwFLRh9jg0UlNoNhvR46me23ZCI/DikF7KfzPjW4rQD7QvbCczeftKUoEP+Am6F
+mxOWe8HYpazpc58JolI4msfwy0UslymF7gEe7ZBQBUxtZIq7ucPL3J/udboWVbGF
+qc14fnS81yS+9FKJxlOjBb/BwvQwetcqAhZ827xieD83vnburyUNRImnNy8AWVuS
+LUSnZCxSUmeSA0YVBTxEr3ksXkePGFdbwTUqD8tg3w13sUUOYfyz+0BHzfjxw9jG
+Y4as2lY5sP+soPWAEZiyLKmw19xNBFWsNW+kVIpEeTR9cnusbFy4oaF12oNSpqR6
+soWWWQ0CP7PT088xDB8ds6T/D1Ydd5Abe6+tStz7rVAH17K5OglO2lDUExNzKTZs
+t9gBYDUGARqFQxF69HnHAAh9+n0Zr99RWC/M0ZsbOipZfk4kxZ3ZgW4H/q1o1moE
+1Qk118W5kicd84XV8xVsO3Mkxo3qwPTMY8hmbM1w4fHU5p8IdjuecD8GOe6AHcLw
+u3tSCNtXWihV2s+yE4k92L6PwVpXuyx73GNghdH11lmOQaPTxmIeUXbmum0C3fUv
+3AcpWL++4HFmioeA69oSEtDTM0/bXxW1Wp79vaqF85GmNceVlsf3vXDqJeRkI1dY
+8TdXRYK5Ag0EXxUYgwEQALNeofteBhFGyA+FsG2QL8BpXggu/e1A33oXuiPL0mL1
+4VhPvNPwk5kyECAj7rhfcvvdEFX/0Qn10Ap4Gjq9VszH9w9m8pVvhFfung/8wYy5
+MCP/P95Erv8wfCEmBh4cWolHZpdeaw5z4zwD+yRuUpVvNHdROo+GxypxW06+T8mE
+dhD/pxMEUh7fGKtBqKGgbLM0VTtPRdvDHKU4pbOPuz4nk6IzFIA+XAeblVHE4kqe
+nxQFZcqGYh9wdHA14m3bDD7vqHcM12XaDasMyN7rTP8njwn9gDxPVVeZ/zbGzCX2
+Qr48EuSlx3MrKPfjvqE0dsvDMj7+U4TfcGk1cM8tnryyK7m4K5Jo3wdQ3edCovUb
+gavtCIGL3qVfPbzC9dk5wRgWi/+lbTc6xsZHEFBnfeamserhCsIFwuVYn1XoSpHY
+6xPuCjouukQHJ252SpU2wQtuOeDyp9dZhimh+ZdVClB6VK733cPnuhfCxz9BkRy3
+BlJx/gtpt/qrn1PFeHNJ3LIGoY7K4W2hASTbi38i1mNJZDlL1XCg6yAXBvtb4E9f
+ERVoofCS+CE1LQo/hIYxu0VKi0frbqRI9LmJa7QGo0Eb++W6E6yjFgsM0yymfmpk
+PLLpIkUZQwfoPKB9JxtwFBOs4M//L9fQLbVdvi958txtW8JyjNxFvexhexRr6UCd
+ABEBAAGJAjwEGAEIACYWIQSLmAAFqyMi98hfEwMfFZf5m85RoQUCXxUYgwIbDAUJ
+BaOagAAKCRAfFZf5m85RoUK+D/4uVIDzbq6HgI9aBc/ZPN+FtiHqUZpS6jiWOxZ9
+M9rwwjFyQ85bqxKqOjN1E1VBR2qlHKW+vwyjrRJs4W8QM9fCNhwQw6Jzk2+WHsSm
+8aBNxShBNxo3Q1diM1YADKSAVUZtB4MwBxANZ3psEt889nju1lmXRYuIDa2TBxFo
+/602vpAbcFIZN6sFVDLXrpOSHiOvKfujqqEm0ARi7I6zenOHxyk0Iljq1z1xeDs6
+hZzDYL5Xg2ym3jCcCtxB1vtyBD5jdKkxm8t3PtVKNsJk9bMo2uIvw3gljh9M93Pt
+PfmkpDphAxeQrueAu9qnrtzibfG+CGAfF9yNGjc/9KG7yPI1bbssVmf05iSQ/WmL
+4rYiI/BP9ri28x0AaPu9Ydw2J98+6latS2E/j56V2gOOPPebS+n0FRRCl+fm/rnt
+rEBWpeMkOUCHJdtWQtcMMLjUo9va1C8iTV7EYvELRt5FFRod7N69nZB3I5745QJZ
+PuBexjxG59JDe4U7+110TrmwDBCPmETlvfPC+HoOKm6VepY/2glpFAx/Wm3qT8q1
+A409KJqS9FirOkCwd4Xua0HnqnyjPY8VLpvJNDIPDKiCNMWVC30Tkp8JwAqBKF98
+//0DlRhGgmwWXciEj8Cnz42RFb3jZE16YSQNqmnXQNt1ImJrbbwb/TY5t1qwauc8
+y2k9og==
+=ABFE
+-END PGP PUBLIC KEY BLOCK-




[calcite] branch master updated: Update history doc to add breaking changes

2020-07-18 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7a462f2  Update history doc to add breaking changes
7a462f2 is described below

commit 7a462f2b2f78aa12068b691c1e423ea4c8a825e4
Author: Haisheng Yuan 
AuthorDate: Sat Jul 18 15:05:18 2020 -0500

Update history doc to add breaking changes
---
 site/_docs/history.md | 4 
 1 file changed, 4 insertions(+)

diff --git a/site/_docs/history.md b/site/_docs/history.md
index f21942f..c9196d5 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -36,6 +36,10 @@ Downloads are available on the
   Mark `CalcMergeRule` as `TransformationRule`
 * [https://issues.apache.org/jira/browse/CALCITE-4003;>CALCITE-4003]
   Disallow cross convention matching and `PhysicalNode` generation in 
`TransformationRule`
+* [https://issues.apache.org/jira/browse/CALCITE-3786;>CALCITE-3786]
+  Change `RelNode#recomputeDigest()` return type from `String` to `void`. To 
get
+  digest string, use `RelNode#getDigest()` instead, it will create new digest
+  string on each call, so don't forget to cache the result if necessary
 
 ## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-23
 {: #v1-23-0}



[calcite] branch master updated: Remove duplicate method equalsSansConvention()

2020-07-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7650466  Remove duplicate method equalsSansConvention()
7650466 is described below

commit 7650466bc8de345d567e7a26f0cc4e43411bfbf8
Author: Haisheng Yuan 
AuthorDate: Fri Jul 17 22:53:00 2020 -0500

Remove duplicate method equalsSansConvention()
---
 .../java/org/apache/calcite/plan/RelTraitSet.java  |  3 +++
 .../calcite/plan/volcano/TopDownRuleDriver.java| 25 ++
 2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java 
b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
index 22c59b1..3902b58 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
@@ -304,6 +304,9 @@ public final class RelTraitSet extends 
AbstractList {
 if (this == other) {
   return true;
 }
+if (this.size() != other.size()) {
+  return false;
+}
 for (int i = 0; i < traits.length; i++) {
   if (traits[i].getTraitDef() == ConventionTraitDef.INSTANCE) {
 continue;
diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
index c85c8e1..f67f133 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
@@ -16,10 +16,8 @@
  */
 package org.apache.calcite.plan.volcano;
 
-import org.apache.calcite.plan.ConventionTraitDef;
 import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCost;
-import org.apache.calcite.plan.RelTrait;
 import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.PhysicalNode;
 import org.apache.calcite.rel.RelNode;
@@ -854,8 +852,8 @@ class TopDownRuleDriver implements RuleDriver {
 final int numSubset = input.set.subsets.size();
 for (int j = 0; j < numSubset; j++) {
   RelSubset subset = input.set.subsets.get(j);
-  if (!subset.isDelivered() || equalsSansConvention(
-  subset.getTraitSet(), rel.getCluster().traitSet())) {
+  if (!subset.isDelivered() || subset.getTraitSet()
+  .equalsSansConvention(rel.getCluster().traitSet())) {
 // Ideally we should stop deriving new relnodes when the
 // subset's traitSet equals with input traitSet, but
 // in case someone manually builds a physical relnode
@@ -933,25 +931,6 @@ class TopDownRuleDriver implements RuleDriver {
   }
 }
 
-
-/**
- * Returns whether the 2 traitSets are equal without Convention.
- * It assumes they have the same traitDefs order.
- */
-private boolean equalsSansConvention(RelTraitSet ts1, RelTraitSet ts2) {
-  assert ts1.size() == ts2.size();
-  for (int i = 0; i < ts1.size(); i++) {
-RelTrait trait = ts1.getTrait(i);
-if (trait.getTraitDef() == ConventionTraitDef.INSTANCE) {
-  continue;
-}
-if (!trait.equals(ts2.getTrait(i))) {
-  return false;
-}
-  }
-  return true;
-}
-
 @Override public void describe(TaskDescriptor desc) {
   desc.item("mExpr", mExpr).item("group", group);
 }



[calcite] branch master updated: [CALCITE-4127] Remove final from AbstractRelNode#getRelTypeName

2020-07-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 cdf8678  [CALCITE-4127] Remove final from 
AbstractRelNode#getRelTypeName
cdf8678 is described below

commit cdf8678f33f8ea49e5291fce4a4651a24edaf19c
Author: rubenada 
AuthorDate: Fri Jul 17 10:00:52 2020 +0200

[CALCITE-4127] Remove final from AbstractRelNode#getRelTypeName
---
 core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java 
b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index b55c90d..7a528d5 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -179,7 +179,8 @@ public abstract class AbstractRelNode implements RelNode {
 Util.discard(planner);
   }
 
-  public final String getRelTypeName() {
+  // It is not recommended to override this method, but sub-classes can do it 
at their own risk.
+  public String getRelTypeName() {
 String cn = getClass().getName();
 int i = cn.length();
 while (--i >= 0) {



[calcite] branch master updated: Following [CALCITE-3916] Refine comments for top down optimizer (Jinpeng Wang)

2020-07-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 66ce217  Following [CALCITE-3916] Refine comments for top down 
optimizer (Jinpeng Wang)
66ce217 is described below

commit 66ce217cc15e8af9685fcb25148bca65b3901a00
Author: jinpeng.wjp 
AuthorDate: Fri Jul 17 15:49:59 2020 +0800

Following [CALCITE-3916] Refine comments for top down optimizer (Jinpeng 
Wang)

Close #2070
---
 .../calcite/plan/volcano/TopDownRuleDriver.java| 108 +
 1 file changed, 91 insertions(+), 17 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
index 0443159..c85c8e1 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/TopDownRuleDriver.java
@@ -37,6 +37,15 @@ import java.util.Set;
 import java.util.Stack;
 import java.util.function.Predicate;
 
+/**
+ * A rule driver that apply rules in a Top-Down manner.
+ * By ensuring rule applying orders, there could be ways for
+ * space pruning and rule mutual exclusivity check.
+ *
+ * This implementation use tasks to manage rule matches.
+ * A Task is a piece of work to be executed, it may apply some rules
+ * or schedule other tasks
+ */
 class TopDownRuleDriver implements RuleDriver {
 
   private static final Logger LOGGER = CalciteTrace.getPlannerTaskTracer();
@@ -77,12 +86,24 @@ class TopDownRuleDriver implements RuleDriver {
 
   @Override public void drive() {
 TaskDescriptor description = new TaskDescriptor();
+
+// Starting from the root's OptimizeGroup task.
 tasks.push(new OptimizeGroup(planner.root, planner.infCost));
+
+// ensure materialized view roots get explored.
+// Note that implementation rules or enforcement rules are not applied
+// unless the mv is matched
 exploreMaterializationRoots();
-while (!tasks.isEmpty()) {
-  Task task = tasks.pop();
-  description.log(task);
-  task.perform();
+
+try {
+  // Iterates until the root is fully optimized
+  while (!tasks.isEmpty()) {
+Task task = tasks.pop();
+description.log(task);
+task.perform();
+  }
+} catch (VolcanoTimeoutException ex) {
+  LOGGER.warn("Volcano planning times out, cancels the subsequent 
optimization.");
 }
   }
 
@@ -126,6 +147,9 @@ class TopDownRuleDriver implements RuleDriver {
   }
 
   public void onSetMerged(RelSet set) {
+// When RelSets get merged, an optimized group may get extra opportunities.
+// Clear the OPTIMISED state for the RelSubsets and all theirs ancestors
+// so that they will be optimized again
 applyGenerator(null, () -> clearProcessed(set));
   }
 
@@ -146,17 +170,28 @@ class TopDownRuleDriver implements RuleDriver {
 }
   }
 
+  // a callback invoked when a RelNode is going to be added into a RelSubset,
+  // either by Register or Reregister. The task driver should need to schedule
+  // tasks for the new nodes.
   public void onProduce(RelNode node, RelSubset subset) {
+
+// if the RelNode is added to another RelSubset, just ignore it.
+// It should be schedule in the later OptimizeGroup task
 if (applying == null || subset.set
 != VolcanoPlanner.equivRoot(applying.group().set)) {
   return;
 }
 
+// extra callback from each task
 if (!applying.onProduce(node)) {
   return;
 }
 
 if (!planner.isLogical(node)) {
+  // For a physical node, schedule tasks to optimize its inputs.
+  // The upper bound depends on all optimizing RelSubsets that this Rel 
belongs to.
+  // If there are optimizing subsets that comes from the same RelSet,
+  // invoke the passThrough method to generate a candidate for that Subset.
   RelSubset optimizingGroup = null;
   boolean canPassThrough = node instanceof PhysicalNode
   && !passThroughCache.contains(node);
@@ -256,7 +291,8 @@ class TopDownRuleDriver implements RuleDriver {
   }
 
   /**
-   * O_GROUP.
+   * Optimize a RelSubset.
+   * It schedule optimization tasks for RelNodes in the RelSet.
*/
   private class OptimizeGroup implements Task {
 private final RelSubset group;
@@ -274,7 +310,7 @@ class TopDownRuleDriver implements RuleDriver {
   }
 
   if (group.taskState != null && upperBound.isLe(group.upperBound)) {
-// this group failed to optimize before or it is a ring
+// either this group failed to optimize before or it is a ring
 return;
   }
 
@@ -313,7 +349,9 @@ class TopDownRuleDriver implements RuleDriver {
   }
 
   /**
-   * Mark the group optimized.
+   * Mark the RelSubset optimized.
+   * When GroupOptimized retur

[calcite] branch master updated: [CALCITE-4124] Stop invalidating metadata cache in VolcanoRuleCall

2020-07-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 88d4de0  [CALCITE-4124] Stop invalidating metadata cache in 
VolcanoRuleCall
88d4de0 is described below

commit 88d4de0f800b84ae10a7a5be8a6c96eeb30eedf7
Author: Haisheng Yuan 
AuthorDate: Wed Jul 15 11:12:02 2020 -0500

[CALCITE-4124] Stop invalidating metadata cache in VolcanoRuleCall

After CALCITE-2018, we don't need to invalidate metadata cache when a new
RelNode is generated during rule transformation.
---
 core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
index bbc32b5..d4f3f03 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
@@ -147,7 +147,6 @@ public class VolcanoRuleCall extends RelOptRuleCall {
   // The subset is not used, but we need it, just for debugging
   //noinspection unused
   RelSubset subset = volcanoPlanner.ensureRegistered(rel, rels[0]);
-  rels[0].getCluster().invalidateMetadataQuery();
 
   if (volcanoPlanner.getListener() != null) {
 RelOptListener.RuleProductionEvent event =



[calcite] branch master updated: [CALCITE-3916] Support top-down rule applying and upper bound space pruning

2020-07-14 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 33aa61c  [CALCITE-3916] Support top-down rule applying and upper bound 
space pruning
33aa61c is described below

commit 33aa61ca404018cc9fe8ad2ec2c02ba269c67ebe
Author: jinpeng.wjp 
AuthorDate: Tue May 26 17:49:41 2020 +0800

[CALCITE-3916] Support top-down rule applying and upper bound space pruning

Close #1991
---
 .../calcite/interpreter/BindableConvention.java|   5 +
 .../org/apache/calcite/plan/RelOptRuleOperand.java |   2 +-
 .../calcite/plan/volcano/IterativeRuleDriver.java  |  88 ++
 .../{RuleQueue.java => IterativeRuleQueue.java}|  84 +-
 .../apache/calcite/plan/volcano/OptimizeTask.java  | 372 -
 .../org/apache/calcite/plan/volcano/RelSet.java|  67 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  87 +-
 .../apache/calcite/plan/volcano/RuleDriver.java|  53 ++
 .../org/apache/calcite/plan/volcano/RuleQueue.java | 280 +--
 .../calcite/plan/volcano/TopDownRuleDriver.java| 898 +
 .../calcite/plan/volcano/TopDownRuleQueue.java |  88 ++
 .../calcite/plan/volcano/VolcanoPlanner.java   | 196 +++--
 .../calcite/rel/metadata/BuiltInMetadata.java  |  17 +-
 .../rel/metadata/DefaultRelMetadataProvider.java   |   1 +
 .../calcite/rel/metadata/RelMdLowerBoundCost.java  |  77 ++
 .../calcite/rel/metadata/RelMetadataQuery.java |  18 +
 .../java/org/apache/calcite/tools/Programs.java|   3 +-
 .../org/apache/calcite/util/BuiltInMethod.java |   4 +
 .../calcite/plan/volcano/VolcanoPlannerTest.java   |  13 +-
 .../org/apache/calcite/test/JdbcAdapterTest.java   |   3 +
 .../org/apache/calcite/test/TopDownOptTest.xml |  92 +--
 .../calcite/adapter/kafka/KafkaAdapterTest.java|   2 +
 22 files changed, 1577 insertions(+), 873 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/interpreter/BindableConvention.java 
b/core/src/main/java/org/apache/calcite/interpreter/BindableConvention.java
index bae22e9..31a4cba 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/BindableConvention.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/BindableConvention.java
@@ -22,6 +22,7 @@ import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelTrait;
 import org.apache.calcite.plan.RelTraitDef;
 import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelNode;
 
 /**
  * Calling convention that returns results as an
@@ -51,6 +52,10 @@ public enum BindableConvention implements Convention {
 return "BINDABLE";
   }
 
+  @Override public RelNode enforce(RelNode input, RelTraitSet required) {
+return null;
+  }
+
   public RelTraitDef getTraitDef() {
 return ConventionTraitDef.INSTANCE;
   }
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
index 7515140..913db6f 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptRuleOperand.java
@@ -47,7 +47,7 @@ public class RelOptRuleOperand {
   public int[] solveOrder;
   public int ordinalInParent;
   public int ordinalInRule;
-  private final RelTrait trait;
+  public final RelTrait trait;
   private final Class clazz;
   private final ImmutableList children;
 
diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
new file mode 100644
index 000..3ff8300
--- /dev/null
+++ 
b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan.volcano;
+
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.util.trace.CalciteTrace;
+
+import org.slf4j.Logger;
+
+/***
+ * The algorithm executes repeatedly in a series of phases. In each phase
+ * the exact rules that

[calcite] branch master updated: [CALCITE-4105] Replace Pair with Flat2List in RelDigestWriter

2020-07-13 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7ab6435  [CALCITE-4105] Replace Pair with Flat2List in RelDigestWriter
7ab6435 is described below

commit 7ab643565a695cd46b6013392874c250fc0cb5a0
Author: Haisheng Yuan 
AuthorDate: Fri Jul 3 15:51:31 2020 -0500

[CALCITE-4105] Replace Pair with Flat2List in RelDigestWriter
---
 .../org/apache/calcite/plan/volcano/RelSubset.java |  8 +++
 .../org/apache/calcite/rel/AbstractRelNode.java| 27 ++
 .../java/org/apache/calcite/rel/core/Filter.java   |  4 
 .../java/org/apache/calcite/rel/core/Join.java |  4 
 .../java/org/apache/calcite/rel/core/Project.java  |  4 
 .../main/java/org/apache/calcite/rex/RexCall.java  |  1 -
 6 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
index f77b5c7..afecdce 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
@@ -240,6 +240,14 @@ public class RelSubset extends AbstractRelNode {
 pw.done(input);
   }
 
+  @Override protected boolean digestEquals(Object obj) {
+return this == obj;
+  }
+
+  @Override protected int digestHash() {
+return this.hashCode();
+  }
+
   @Override protected RelDataType deriveRowType() {
 return set.rel.getRowType();
   }
diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java 
b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index ce71993..b55c90d 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -28,12 +28,14 @@ import org.apache.calcite.plan.RelOptUtil;
 import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.core.CorrelationId;
 import org.apache.calcite.rel.hint.Hintable;
+import org.apache.calcite.rel.hint.RelHint;
 import org.apache.calcite.rel.metadata.Metadata;
 import org.apache.calcite.rel.metadata.MetadataFactory;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexShuttle;
+import org.apache.calcite.runtime.FlatLists;
 import org.apache.calcite.sql.SqlExplainLevel;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.Litmus;
@@ -405,6 +407,7 @@ public abstract class AbstractRelNode implements RelNode {
* @return Whether the 2 RelNodes are equivalent or have the same digest.
* @see #digestHash()
*/
+  @API(since = "1.24", status = API.Status.EXPERIMENTAL)
   protected boolean digestEquals(Object obj) {
 if (this == obj) {
   return true;
@@ -423,17 +426,19 @@ public abstract class AbstractRelNode implements RelNode {
*
* @see #digestEquals(Object)
*/
+  @API(since = "1.24", status = API.Status.EXPERIMENTAL)
   protected int digestHash() {
 return Objects.hash(getTraitSet(), getDigestItems());
   }
 
-  private List> getDigestItems() {
+  private List> getDigestItems() {
 RelDigestWriter rdw = new RelDigestWriter();
 explainTerms(rdw);
 if (this instanceof Hintable) {
-  rdw.item("hints", ((Hintable) this).getHints());
+  List hints = ((Hintable) this).getHints();
+  rdw.itemIf("hints", hints, !hints.isEmpty());
 }
-return rdw.values;
+return rdw.attrs;
   }
 
   private class InnerRelDigest implements RelDigest {
@@ -485,7 +490,7 @@ public abstract class AbstractRelNode implements RelNode {
*/
   private static final class RelDigestWriter implements RelWriter {
 
-private final List> values = new ArrayList<>();
+private final List> attrs = new ArrayList<>();
 
 String digest = null;
 
@@ -503,7 +508,7 @@ public abstract class AbstractRelNode implements RelNode {
 // convert it to String to keep the same behaviour.
 value = "" + value;
   }
-  values.add(Pair.of(term, value));
+  attrs.add(FlatLists.of(term, value));
   return this;
 }
 
@@ -514,19 +519,21 @@ public abstract class AbstractRelNode implements RelNode {
   sb.append(node.getTraitSet());
   sb.append('(');
   int j = 0;
-  for (Pair value : values) {
+  for (List attr : attrs) {
+String key = (String) attr.get(0);
+Object value = attr.get(1);
 if (j++ > 0) {
   sb.append(',');
 }
-sb.append(value.left);
+sb.append(key);
 sb.append('=');
-if (value.right instanceof RelNode) {
-  RelNode input = (RelNode) value.right;
+ 

[calcite] branch master updated: [CALCITE-4097] Avoid requesting unnecessary trait request when deriving traits

2020-07-01 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 640da7c  [CALCITE-4097] Avoid requesting unnecessary trait request 
when deriving traits
640da7c is described below

commit 640da7c6d85c3e83fe38fb45d7f23ef5e1000c4e
Author: Haisheng Yuan 
AuthorDate: Tue Jun 30 20:12:25 2020 -0500

[CALCITE-4097] Avoid requesting unnecessary trait request when deriving 
traits

If the child subset is used to derive new traits for current relnode, the
subset will be marked REQUIRED when registering the new derived relnode and
later will add enforcers between other delivered subsets.  e.g. a MergeJoin
request both inputs hash distributed by [a,b] sorted by [a,b]. If the left
input R1 happens to be distributed by [a], the MergeJoin can derive new 
traits
from this input and request both input to be distributed by [a] sorted by
[a,b]. In case there is a alternative R2 with ANY distribution in the left
input's RelSet, we end up with requesting hash distribution [a] on 
alternative
R2, which is unnecessary and waste, because we request distribution by [a]
because of R1 can deliver the exact same distribution and we don't need to
enforce properties on other subsets that can't satisfy the specific trait
requirement.
---
 .../apache/calcite/plan/volcano/OptimizeTask.java  | 29 +-
 .../org/apache/calcite/plan/volcano/RelSet.java|  8 +++---
 .../org/apache/calcite/plan/volcano/RelSubset.java | 17 +
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java
index 71fb037..c72e2b8 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java
@@ -199,7 +199,6 @@ abstract class OptimizeTask {
   RelSubset subset = input.set.subsets.get(j);
   if (!subset.isDelivered() || equalsSansConvention(
   subset.getTraitSet(), rel.getCluster().traitSet())) {
-// TODO: should use matching type to determine
 // Ideally we should stop deriving new relnodes when the
 // subset's traitSet equals with input traitSet, but
 // in case someone manually builds a physical relnode
@@ -227,6 +226,34 @@ abstract class OptimizeTask {
   } else {
 RelNode newRel = rel.derive(subset.getTraitSet(), childId);
 if (newRel != null && !planner.isRegistered(newRel)) {
+  RelNode newInput = newRel.getInput(childId);
+  assert newInput instanceof RelSubset;
+  if (newInput == subset) {
+// If the child subset is used to derive new traits for
+// current relnode, the subset will be marked REQUIRED
+// when registering the new derived relnode and later
+// will add enforcers between other delivered subsets.
+// e.g. a MergeJoin request both inputs hash distributed
+// by [a,b] sorted by [a,b]. If the left input R1 happens to
+// be distributed by [a], the MergeJoin can derive new
+// traits from this input and request both input to be
+// distributed by [a] sorted by [a,b]. In case there is a
+// alternative R2 with ANY distribution in the left input's
+// RelSet, we may end up with requesting hash distribution
+// [a] on alternative R2, which is unnecessary and waste,
+// because we request distribution by [a] because of R1 can
+// deliver the exact same distribution and we don't need to
+// enforce properties on other subsets that can't satisfy
+// the specific trait requirement.
+// Here we add a constraint that {@code newInput == subset},
+// because if the delivered child subset is HASH[a], but
+// we require HASH[a].SORT[a,b], we still need to enable
+// property enforcement on the required subset. Otherwise,
+// we need to restrict enforcement between HASH[a].SORT[a,b]
+// and HASH[a] only, which will make things a little bit
+// complicated. We might optimize it in the future.
+subset.disableEnforcing();
+  }
   RelSubset relSubset = planner.register(newRel, node);
   assert relSubset.set == planner.getSubset(node).set;
 }
diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
index

[calcite] branch master updated: [CALCITE-3786] Make digestEquals and digestHash available to be overridden

2020-06-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 af3bca3  [CALCITE-3786] Make digestEquals and digestHash available to 
be overridden
af3bca3 is described below

commit af3bca328a40d2d6515ea00e2094974cc725d4c3
Author: Haisheng Yuan 
AuthorDate: Tue Jun 23 17:20:37 2020 -0500

[CALCITE-3786] Make digestEquals and digestHash available to be overridden

By default #digestEquals() and #digestHash() collect digest attributes from
compute hash code. This should work well for most cases. If the method is a
performance bottleneck for your project, or the default behavior can't 
handle
your scenario properly, you can choose to override #digestEquals() and
Only these operators are changed to override the default behavior, for
performance and demonstration purposes. All the other operators remain
unchanged.

Close #2044
---
 .../java/org/apache/calcite/plan/RelOptNode.java   | 15 +--
 .../org/apache/calcite/plan/hep/HepRelVertex.java  | 11 +---
 .../org/apache/calcite/rel/AbstractRelNode.java| 26 --
 .../main/java/org/apache/calcite/rel/RelNode.java  | 24 ++---
 .../java/org/apache/calcite/rel/core/Filter.java   | 19 +
 .../java/org/apache/calcite/rel/core/Join.java | 21 +++
 .../java/org/apache/calcite/rel/core/Project.java  | 20 ++
 .../apache/calcite/rel/logical/LogicalFilter.java  |  9 +++
 .../apache/calcite/rel/logical/LogicalJoin.java| 13 +
 .../apache/calcite/rel/logical/LogicalProject.java |  8 ++
 .../org/apache/calcite/rel/type/RelDataType.java   | 31 ++
 11 files changed, 169 insertions(+), 28 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java 
b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
index 208a87c..c21f745 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
@@ -18,8 +18,6 @@ package org.apache.calcite.plan;
 
 import org.apache.calcite.rel.type.RelDataType;
 
-import org.apiguardian.api.API;
-
 import java.util.List;
 
 /**
@@ -49,18 +47,7 @@ public interface RelOptNode {
*
* @return Digest string of this {@code RelNode}
*/
-  default String getDigest() {
-return getRelDigest().toString();
-  }
-
-  /**
-   * Digest of the {@code RelNode}, for planner internal use only.
-   *
-   * @return Digest of this {@code RelNode}
-   * @see #getDigest()
-   */
-  @API(since = "1.24", status = API.Status.INTERNAL)
-  RelDigest getRelDigest();
+  String getDigest();
 
   /**
* Retrieves this RelNode's traits. Note that although the RelTraitSet
diff --git a/core/src/main/java/org/apache/calcite/plan/hep/HepRelVertex.java 
b/core/src/main/java/org/apache/calcite/plan/hep/HepRelVertex.java
index 1061a61..4ad6d28 100644
--- a/core/src/main/java/org/apache/calcite/plan/hep/HepRelVertex.java
+++ b/core/src/main/java/org/apache/calcite/plan/hep/HepRelVertex.java
@@ -91,9 +91,14 @@ public class HepRelVertex extends AbstractRelNode {
 return currentRel;
   }
 
-  @Override public RelWriter explainTerms(final RelWriter pw) {
-return super.explainTerms(pw)
-.item("currentRel", currentRel.getId());
+  @Override protected boolean digestEquals(Object obj) {
+return this == obj
+|| (obj instanceof HepRelVertex
+&& currentRel == ((HepRelVertex) obj).currentRel);
+  }
+
+  @Override protected int digestHash() {
+return currentRel.getId();
   }
 
   @Override public String getDigest() {
diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java 
b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index 4ab68a0..ec52c10 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -337,9 +337,8 @@ public abstract class AbstractRelNode implements RelNode {
 return r;
   }
 
-  public RelDigest recomputeDigest() {
+  public void recomputeDigest() {
 digest.clear();
-return digest;
   }
 
   public void replaceInput(
@@ -394,9 +393,19 @@ public abstract class AbstractRelNode implements RelNode {
   }
 
   /**
-   * Equality check for RelNode digest
+   * Equality check for RelNode digest.
+   *
+   * By default this method collects digest attributes from
+   * {@link #explainTerms(RelWriter)}, then compares each attribute pair.
+   * This should work well for most cases. If this method is a performance
+   * bottleneck for your project, or the default behavior can't handle
+   * your scenario properly, you can choose to override this method and
+   * {@link #digestHash()}. See {@code LogicalJoin} as an example.
+   *

[calcite] branch master updated: [CALCITE-4083] RelTraitSet failed to canonize traits

2020-06-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 0769a8b  [CALCITE-4083] RelTraitSet failed to canonize traits
0769a8b is described below

commit 0769a8b31cbbeb5bca66ade30cf3710523da4aaa
Author: Haisheng Yuan 
AuthorDate: Mon Jun 22 17:14:34 2020 -0500

[CALCITE-4083] RelTraitSet failed to canonize traits

RelTraitSet#plus uses FlatLists and ImmutableList. They have different hash
algorithms, and they are all different classes from RelTraitSet. The
RelTraitSet equality requires the other object must be RelTraitSet too, and 
the
HashMap#get(key) uses key.equals() to check equality, instead of the other 
way.
In case we pass RelTraitSet as the search key to cache, but the cached entry
has key with FlatLists or ImmutableList, we may fail to find the cached
RelTraitSet. Due to this, using == to check traitSet equality may fail, even
they have same traits.

Also modified hashCode() of RelDataTypeFieldImpl, the original 
implementation
generates hash collision easily.

Close #2041
---
 .../java/org/apache/calcite/plan/RelTraitSet.java  | 52 ++
 .../org/apache/calcite/plan/volcano/RelSet.java|  2 +-
 .../calcite/rel/type/RelDataTypeFieldImpl.java |  5 +--
 3 files changed, 16 insertions(+), 43 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java 
b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
index c521968..22c59b1 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
@@ -20,7 +20,6 @@ import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelCollationTraitDef;
 import org.apache.calcite.rel.RelDistribution;
 import org.apache.calcite.rel.RelDistributionTraitDef;
-import org.apache.calcite.runtime.FlatLists;
 import org.apache.calcite.util.mapping.Mappings;
 
 import com.google.common.collect.ImmutableList;
@@ -42,9 +41,9 @@ public final class RelTraitSet extends AbstractList 
{
 
   private final Cache cache;
   private final RelTrait[] traits;
-  private final String string;
+  private String string;
   /** Cache the hash code for the traits */
-  private int hash = 0;
+  private int hash; // Default to 0
 
   //~ Constructors ---
 
@@ -61,7 +60,6 @@ public final class RelTraitSet extends AbstractList 
{
 //   the caller has made a copy.
 this.cache = cache;
 this.traits = traits;
-this.string = computeString();
   }
 
   //~ Methods 
@@ -561,6 +559,9 @@ public final class RelTraitSet extends 
AbstractList {
   }
 
   @Override public String toString() {
+if (string == null) {
+  string = computeString();
+}
 return string;
   }
 
@@ -620,29 +621,12 @@ public final class RelTraitSet extends 
AbstractList {
 if (i >= 0) {
   return replace(i, trait);
 }
-// Optimize time & space to represent a trait set key.
-//
-// Don't build a trait set until we're sure there isn't an equivalent one.
-// Then we can justify the cost of computing RelTraitSet.string in the
-// constructor.
 final RelTrait canonizedTrait = canonize(trait);
 assert canonizedTrait != null;
-List newTraits;
-switch (traits.length) {
-case 0:
-  newTraits = ImmutableList.of(canonizedTrait);
-  break;
-case 1:
-  newTraits = FlatLists.of(traits[0], canonizedTrait);
-  break;
-case 2:
-  newTraits = FlatLists.of(traits[0], traits[1], canonizedTrait);
-  break;
-default:
-  newTraits = ImmutableList.builder().add(traits)
-  .add(canonizedTrait).build();
-}
-return cache.getOrAdd(newTraits);
+RelTrait[] newTraits = new RelTrait[traits.length + 1];
+System.arraycopy(traits, 0, newTraits, 0, traits.length);
+newTraits[traits.length] = canonizedTrait;
+return cache.getOrAdd(new RelTraitSet(cache, newTraits));
   }
 
   public RelTraitSet plusAll(RelTrait[] traits) {
@@ -704,24 +688,14 @@ public final class RelTraitSet extends 
AbstractList {
 
   /** Cache of trait sets. */
   private static class Cache {
-final Map, RelTraitSet> map = new HashMap<>();
+final Map map = new HashMap<>();
 
 Cache() {
 }
 
-RelTraitSet getOrAdd(List traits) {
-  RelTraitSet traitSet1 = map.get(traits);
-  if (traitSet1 != null) {
-return traitSet1;
-  }
-  final RelTraitSet traitSet;
-  if (traits instanceof RelTraitSet) {
-traitSet = (RelTraitSet) traits;
-  } else {
-traitSet = new RelTraitSet(this, traits.toArray(new RelTrait[0]));
-  }
-  map.put(traits, traitSet);

[calcite] branch master updated: [CALCITE-3786] Rework digest for RelNode and RexCall

2020-06-22 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 1736242  [CALCITE-3786] Rework digest for RelNode and RexCall
1736242 is described below

commit 1736242612634359164be483334884cb9113f804
Author: Haisheng Yuan 
AuthorDate: Wed Jun 17 06:07:00 2020 -0500

[CALCITE-3786] Rework digest for RelNode and RexCall

Close #2039
---
 .../main/java/org/apache/calcite/plan/Digest.java  | 232 -
 .../java/org/apache/calcite/plan/RelDigest.java|  42 
 .../java/org/apache/calcite/plan/RelOptNode.java   |  15 +-
 .../java/org/apache/calcite/plan/RelOptUtil.java   |   1 +
 .../org/apache/calcite/plan/hep/HepPlanner.java|  12 +-
 .../org/apache/calcite/plan/hep/HepRelVertex.java  |  14 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  16 +-
 .../calcite/plan/volcano/VolcanoPlanner.java   |  57 ++---
 .../org/apache/calcite/rel/AbstractRelNode.java| 140 ++---
 .../main/java/org/apache/calcite/rel/RelNode.java  |   7 +-
 .../java/org/apache/calcite/rel/SingleRel.java |   1 +
 .../java/org/apache/calcite/rel/core/Window.java   |   5 +-
 .../rel/metadata/JaninoRelMetadataProvider.java|   7 +-
 .../org/apache/calcite/rel/rules/MultiJoin.java|   1 +
 .../main/java/org/apache/calcite/rex/RexCall.java  |  23 +-
 .../org/apache/calcite/rex/RexDynamicParam.java|   3 +-
 .../java/org/apache/calcite/rex/RexLiteral.java|   3 +
 .../main/java/org/apache/calcite/rex/RexOver.java  |   6 +-
 .../java/org/apache/calcite/rex/RexSubQuery.java   |   8 +-
 .../org/apache/calcite/test/HepPlannerTest.java|   2 +-
 20 files changed, 263 insertions(+), 332 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/Digest.java 
b/core/src/main/java/org/apache/calcite/plan/Digest.java
deleted file mode 100644
index e7375bf..000
--- a/core/src/main/java/org/apache/calcite/plan/Digest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.calcite.plan;
-
-import org.apache.calcite.rel.RelNode;
-import org.apache.calcite.rel.hint.Hintable;
-import org.apache.calcite.rel.type.RelDataType;
-import org.apache.calcite.util.Pair;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.Nonnull;
-
-/**
- * A short description of relational expression's type, inputs, and
- * other properties. The digest uniquely identifies the node; another node
- * is equivalent if and only if it has the same value.
- *
- * Row type is part of the digest for the rare occasion that similar
- * expressions have different types, e.g. variants of
- * {@code Project(child=rel#1, a=null)} where a is a null INTEGER or a
- * null VARCHAR(10). Row type is represented as fieldTypes only, so {@code 
RelNode}
- * that differ with field names only are treated equal.
- * For instance, {@code Project(input=rel#1,empid=$0)} and {@code 
Project(input=rel#1,deptno=$0)}
- * are equal.
- *
- * Computed by {@code org.apache.calcite.rel.AbstractRelNode#computeDigest},
- * assigned by {@link org.apache.calcite.rel.AbstractRelNode#onRegister},
- * returned by {@link org.apache.calcite.rel.AbstractRelNode#getDigest()}.
- */
-public class Digest implements Comparable {
-
-  //~ Instance fields 
-
-  private final int hashCode;
-  private final List> items;
-  private final RelNode rel;
-
-  // Used for debugging, computed lazily.
-  private String digest = null;
-
-  //~ Constructors ---
-
-  /**
-   * Creates a digest with given rel and properties.
-   *
-   * @param rel   The rel
-   * @param items The properties, e.g. the inputs, the operands and so on
-   */
-  private Digest(RelNode rel, List> items) {
-this.rel = rel;
-this.items = normalizeContents(items);
-this.hashCode = computeIdentity(rel, this.items);
-  }
-
-  /** Creates a digest with given rel and string format digest. */
-  private 

[calcite] branch master updated (69f2586 -> b00c1fd)

2020-06-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 69f2586  [CALCITE-3786] Add Digest interface to enable efficient 
hashCode(equals) for RexNode and RelNode
 add b00c1fd  [CALCITE-4056] Remove Digest from RelNode and RexCall

No new revisions were added by this update.

Summary of changes:
 .../adapter/enumerable/EnumerableAggregate.java|   8 +
 .../adapter/enumerable/EnumerableFilter.java   |   8 +
 .../adapter/enumerable/EnumerableHashJoin.java |   8 +
 .../adapter/enumerable/EnumerableMergeJoin.java|   8 +
 .../enumerable/EnumerableNestedLoopJoin.java   |   8 +
 .../adapter/enumerable/EnumerableProject.java  |   8 +
 .../enumerable/EnumerableSortedAggregate.java  |   8 +
 .../main/java/org/apache/calcite/plan/Digest.java  | 256 -
 .../java/org/apache/calcite/plan/RelDigest.java|  52 +
 .../java/org/apache/calcite/plan/RelOptNode.java   |  15 +-
 .../java/org/apache/calcite/plan/RelOptUtil.java   |   1 +
 .../org/apache/calcite/plan/hep/HepPlanner.java|  12 +-
 .../org/apache/calcite/plan/hep/HepRelVertex.java  |  15 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  36 ++-
 .../calcite/plan/volcano/VolcanoPlanner.java   |  55 +++--
 .../org/apache/calcite/rel/AbstractRelNode.java| 135 +--
 .../main/java/org/apache/calcite/rel/RelNode.java  |   7 +-
 .../java/org/apache/calcite/rel/SingleRel.java |   1 +
 .../org/apache/calcite/rel/core/Aggregate.java |  21 ++
 .../java/org/apache/calcite/rel/core/Filter.java   |  19 ++
 .../java/org/apache/calcite/rel/core/Join.java |  22 ++
 .../java/org/apache/calcite/rel/core/Project.java  |  21 ++
 .../java/org/apache/calcite/rel/core/Values.java   |  18 ++
 .../java/org/apache/calcite/rel/core/Window.java   |   5 +-
 .../calcite/rel/logical/LogicalAggregate.java  |   8 +
 .../apache/calcite/rel/logical/LogicalFilter.java  |  12 +
 .../apache/calcite/rel/logical/LogicalJoin.java|  13 ++
 .../apache/calcite/rel/logical/LogicalProject.java |   8 +
 .../rel/metadata/JaninoRelMetadataProvider.java|   7 +-
 .../org/apache/calcite/rel/rules/MultiJoin.java|   1 +
 .../main/java/org/apache/calcite/rex/RexCall.java  |  18 +-
 .../org/apache/calcite/rex/RexDynamicParam.java|   6 +-
 .../java/org/apache/calcite/rex/RexLiteral.java|   8 +-
 .../main/java/org/apache/calcite/rex/RexNode.java  |   5 +
 .../main/java/org/apache/calcite/rex/RexOver.java  |   6 +-
 .../java/org/apache/calcite/rex/RexSubQuery.java   |   8 +-
 .../org/apache/calcite/test/HepPlannerTest.java|   2 +-
 37 files changed, 495 insertions(+), 354 deletions(-)
 delete mode 100644 core/src/main/java/org/apache/calcite/plan/Digest.java
 create mode 100644 core/src/main/java/org/apache/calcite/plan/RelDigest.java



[calcite] branch master updated: [CALCITE-4056] Remove Digest from RelNode and RexCall

2020-06-17 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 b00c1fd  [CALCITE-4056] Remove Digest from RelNode and RexCall
b00c1fd is described below

commit b00c1fd6e26b5e3cc1a810c9f862b184649cd1a6
Author: Haisheng Yuan 
AuthorDate: Wed Jun 17 06:07:00 2020 -0500

[CALCITE-4056] Remove Digest from RelNode and RexCall

Close #2032
---
 .../adapter/enumerable/EnumerableAggregate.java|   8 +
 .../adapter/enumerable/EnumerableFilter.java   |   8 +
 .../adapter/enumerable/EnumerableHashJoin.java |   8 +
 .../adapter/enumerable/EnumerableMergeJoin.java|   8 +
 .../enumerable/EnumerableNestedLoopJoin.java   |   8 +
 .../adapter/enumerable/EnumerableProject.java  |   8 +
 .../enumerable/EnumerableSortedAggregate.java  |   8 +
 .../main/java/org/apache/calcite/plan/Digest.java  | 256 -
 .../java/org/apache/calcite/plan/RelDigest.java|  52 +
 .../java/org/apache/calcite/plan/RelOptNode.java   |  15 +-
 .../java/org/apache/calcite/plan/RelOptUtil.java   |   1 +
 .../org/apache/calcite/plan/hep/HepPlanner.java|  12 +-
 .../org/apache/calcite/plan/hep/HepRelVertex.java  |  15 +-
 .../org/apache/calcite/plan/volcano/RelSubset.java |  36 ++-
 .../calcite/plan/volcano/VolcanoPlanner.java   |  55 +++--
 .../org/apache/calcite/rel/AbstractRelNode.java| 135 +--
 .../main/java/org/apache/calcite/rel/RelNode.java  |   7 +-
 .../java/org/apache/calcite/rel/SingleRel.java |   1 +
 .../org/apache/calcite/rel/core/Aggregate.java |  21 ++
 .../java/org/apache/calcite/rel/core/Filter.java   |  19 ++
 .../java/org/apache/calcite/rel/core/Join.java |  22 ++
 .../java/org/apache/calcite/rel/core/Project.java  |  21 ++
 .../java/org/apache/calcite/rel/core/Values.java   |  18 ++
 .../java/org/apache/calcite/rel/core/Window.java   |   5 +-
 .../calcite/rel/logical/LogicalAggregate.java  |   8 +
 .../apache/calcite/rel/logical/LogicalFilter.java  |  12 +
 .../apache/calcite/rel/logical/LogicalJoin.java|  13 ++
 .../apache/calcite/rel/logical/LogicalProject.java |   8 +
 .../rel/metadata/JaninoRelMetadataProvider.java|   7 +-
 .../org/apache/calcite/rel/rules/MultiJoin.java|   1 +
 .../main/java/org/apache/calcite/rex/RexCall.java  |  18 +-
 .../org/apache/calcite/rex/RexDynamicParam.java|   6 +-
 .../java/org/apache/calcite/rex/RexLiteral.java|   8 +-
 .../main/java/org/apache/calcite/rex/RexNode.java  |   5 +
 .../main/java/org/apache/calcite/rex/RexOver.java  |   6 +-
 .../java/org/apache/calcite/rex/RexSubQuery.java   |   8 +-
 .../org/apache/calcite/test/HepPlannerTest.java|   2 +-
 37 files changed, 495 insertions(+), 354 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableAggregate.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableAggregate.java
index a0dee72..9967e2a 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableAggregate.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableAggregate.java
@@ -105,6 +105,14 @@ public class EnumerableAggregate extends Aggregate 
implements EnumerableRel {
 }
   }
 
+  @Override public boolean digestEquals(Object obj) {
+return digestEquals0(obj);
+  }
+
+  @Override public int digestHash() {
+return digestHash0();
+  }
+
   public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
 final JavaTypeFactory typeFactory = implementor.getTypeFactory();
 final BlockBuilder builder = new BlockBuilder();
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableFilter.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableFilter.java
index 5af195c..8d26c7e 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableFilter.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableFilter.java
@@ -71,6 +71,14 @@ public class EnumerableFilter
 return new EnumerableFilter(getCluster(), traitSet, input, condition);
   }
 
+  @Override public boolean digestEquals(Object obj) {
+return digestEquals0(obj);
+  }
+
+  @Override public int digestHash() {
+return digestHash0();
+  }
+
   public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
 // EnumerableCalc is always better
 throw new UnsupportedOperationException();
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
index 918919e..41d5d50 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
@@ -166,6 +166,14

[calcite] branch master updated: [CALCITE-4057] Support trait propagation for EnumerableBatchNestedLoopJoin (Rui Wang)

2020-06-13 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 978bb7e  [CALCITE-4057] Support trait propagation for 
EnumerableBatchNestedLoopJoin (Rui Wang)
978bb7e is described below

commit 978bb7ea44969351468d1b5e240e8f57af7e5770
Author: amaliujia 
AuthorDate: Thu Jun 11 20:38:32 2020 -0700

[CALCITE-4057] Support trait propagation for EnumerableBatchNestedLoopJoin 
(Rui Wang)

Close #2023
---
 .../enumerable/EnumerableBatchNestedLoopJoin.java  | 22 +++
 .../calcite/adapter/enumerable/EnumerableCalc.java |  4 +-
 .../adapter/enumerable/EnumerableCorrelate.java| 34 ++-
 .../adapter/enumerable/EnumerableHashJoin.java | 38 ++--
 .../enumerable/EnumerableNestedLoopJoin.java   | 48 +++
 .../adapter/enumerable/EnumerableProject.java  |  4 +-
 ...TraitsUtils.java => EnumerableTraitsUtils.java} | 69 +-
 .../org/apache/calcite/test/TopDownOptTest.java| 46 ++-
 .../org/apache/calcite/test/TopDownOptTest.xml | 61 +++
 9 files changed, 201 insertions(+), 125 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java
index 13ff1e1..de727c0 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java
@@ -22,6 +22,7 @@ import org.apache.calcite.linq4j.tree.Expression;
 import org.apache.calcite.linq4j.tree.Expressions;
 import org.apache.calcite.linq4j.tree.ParameterExpression;
 import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptCost;
 import org.apache.calcite.plan.RelOptPlanner;
@@ -37,6 +38,7 @@ import org.apache.calcite.rel.metadata.RelMetadataQuery;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
 
 import com.google.common.collect.ImmutableList;
 
@@ -88,6 +90,26 @@ public class EnumerableBatchNestedLoopJoin extends Join 
implements EnumerableRel
 joinType);
   }
 
+  @Override public Pair> passThroughTraits(
+  final RelTraitSet required) {
+return EnumerableTraitsUtils.passThroughTraitsForJoin(
+required, joinType, getLeft().getRowType().getFieldCount(), traitSet);
+  }
+
+  @Override public Pair> deriveTraits(
+  final RelTraitSet childTraits, final int childId) {
+return EnumerableTraitsUtils.deriveTraitsForJoin(
+childTraits, childId, joinType, traitSet, right.getTraitSet());
+  }
+
+  @Override public DeriveMode getDeriveMode() {
+if (joinType == JoinRelType.FULL || joinType == JoinRelType.RIGHT) {
+  return DeriveMode.PROHIBITED;
+}
+
+return DeriveMode.LEFT_FIRST;
+  }
+
   @Override public EnumerableBatchNestedLoopJoin copy(RelTraitSet traitSet,
   RexNode condition, RelNode left, RelNode right, JoinRelType joinType,
   boolean semiJoinDone) {
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCalc.java 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCalc.java
index f899624..f987cbf 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCalc.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCalc.java
@@ -272,7 +272,7 @@ public class EnumerableCalc extends Calc implements 
EnumerableRel {
 final List exps = Lists.transform(program.getProjectList(),
 program::expandLocalRef);
 
-return EnumTraitsUtils.passThroughTraitsForProject(required, exps,
+return EnumerableTraitsUtils.passThroughTraitsForProject(required, exps,
 input.getRowType(), input.getCluster().getTypeFactory(), traitSet);
   }
 
@@ -281,7 +281,7 @@ public class EnumerableCalc extends Calc implements 
EnumerableRel {
 final List exps = Lists.transform(program.getProjectList(),
 program::expandLocalRef);
 
-return EnumTraitsUtils.deriveTraitsForProject(childTraits, childId, exps,
+return EnumerableTraitsUtils.deriveTraitsForProject(childTraits, childId, 
exps,
 input.getRowType(), input.getCluster().getTypeFactory(), traitSet);
   }
 
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
index cc1e56c..86bc042 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
+++ 
b/core/src/main/java/org/apach

[calcite] branch master updated: [CALCITE-4018] Support trait propagation for EnumerableValues

2020-06-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7c5c7e3  [CALCITE-4018] Support trait propagation for EnumerableValues
7c5c7e3 is described below

commit 7c5c7e3b77b6a7606e1295dd7c47815cbbe10871
Author: Haisheng Yuan 
AuthorDate: Tue Jun 9 19:20:50 2020 -0500

[CALCITE-4018] Support trait propagation for EnumerableValues

In addition, add code snippet to demonstrate how to generate IndexScan on
demand by passing required collation through TableScan.
---
 .../adapter/enumerable/EnumerableTableScan.java| 22 +
 .../adapter/enumerable/EnumerableValues.java   | 37 ++
 .../calcite/rel/metadata/RelMdCollation.java   |  2 +-
 .../org/apache/calcite/test/TopDownOptTest.java| 12 +++
 .../org/apache/calcite/test/TopDownOptTest.xml | 37 ++
 5 files changed, 109 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
index fe10098..1381463 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
@@ -29,6 +29,7 @@ import org.apache.calcite.linq4j.tree.MethodCallExpression;
 import org.apache.calcite.linq4j.tree.ParameterExpression;
 import org.apache.calcite.linq4j.tree.Primitive;
 import org.apache.calcite.linq4j.tree.Types;
+import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptTable;
 import org.apache.calcite.plan.RelOptUtil;
@@ -73,6 +74,27 @@ public class EnumerableTableScan
 : "EnumerableTableScan can't implement " + table + ", see 
EnumerableTableScan#canHandle";
   }
 
+  /**
+   * Code snippet to demonstrate how to generate IndexScan on demand
+   * by passing required collation through TableScan.
+   *
+   * @return IndexScan if there is index available on collation keys
+   */
+  @Override public RelNode passThrough(final RelTraitSet required) {
+/*
+keys = required.getCollation().getKeys();
+if (table has index on keys) {
+  direction = forward or backward;
+  return new IndexScan(table, indexInfo, direction);
+}
+*/
+return null;
+  }
+
+  @Override public DeriveMode getDeriveMode() {
+return DeriveMode.PROHIBITED;
+  }
+
   /** Creates an EnumerableTableScan. */
   public static EnumerableTableScan create(RelOptCluster cluster,
   RelOptTable relOptTable) {
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableValues.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableValues.java
index 97b6554..8c6fa5c 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableValues.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableValues.java
@@ -21,10 +21,13 @@ import org.apache.calcite.linq4j.tree.BlockBuilder;
 import org.apache.calcite.linq4j.tree.Expression;
 import org.apache.calcite.linq4j.tree.Expressions;
 import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelCollationTraitDef;
 import org.apache.calcite.rel.RelDistributionTraitDef;
+import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Values;
 import org.apache.calcite.rel.metadata.RelMdCollation;
@@ -37,6 +40,7 @@ import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.Pair;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Ordering;
 
 import java.lang.reflect.Type;
 import java.util.ArrayList;
@@ -70,6 +74,39 @@ public class EnumerableValues extends Values implements 
EnumerableRel {
 return new EnumerableValues(getCluster(), rowType, tuples, traitSet);
   }
 
+  @Override public RelNode passThrough(final RelTraitSet required) {
+RelCollation collation = required.getCollation();
+if (collation == null || collation.isDefault()) {
+  return null;
+}
+
+// A Values with 0 or 1 rows can be ordered by any collation.
+if (tuples.size() > 1) {
+  Ordering> ordering = null;
+  // Generate ordering comparator according to the required collations.
+  for (RelFieldCollation fc : collation.getFieldCollations()) {
+Ordering> comparator = RelMdCollation.comparator(fc);
+if (ordering == null) {
+  ordering = comparator;
+} else {
+  ordering =

[calcite] branch master updated: [CALCITE-4003] Disallow cross convention matching and generation in TransformationRule

2020-06-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 0c8d0fe  [CALCITE-4003] Disallow cross convention matching and 
generation in TransformationRule
0c8d0fe is described below

commit 0c8d0fe2c4b9affdd247ec1f376231e7b961a912
Author: Haisheng Yuan 
AuthorDate: Sun May 17 11:23:10 2020 -0500

[CALCITE-4003] Disallow cross convention matching and generation in 
TransformationRule
---
 .../org/apache/calcite/plan/volcano/VolcanoRuleCall.java | 16 +++-
 .../org/apache/calcite/rel/rules/ProjectRemoveRule.java  |  1 +
 .../org/apache/calcite/rel/rules/SortRemoveRule.java |  3 ++-
 site/_docs/history.md|  2 ++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
index 189a47a..bbc32b5 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoRuleCall.java
@@ -21,8 +21,10 @@ import org.apache.calcite.plan.RelOptListener;
 import org.apache.calcite.plan.RelOptRuleCall;
 import org.apache.calcite.plan.RelOptRuleOperand;
 import org.apache.calcite.plan.RelOptRuleOperandChildPolicy;
+import org.apache.calcite.rel.PhysicalNode;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.rules.SubstitutionRule;
+import org.apache.calcite.rel.rules.TransformationRule;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -92,6 +94,12 @@ public class VolcanoRuleCall extends RelOptRuleCall {
   // implement RelOptRuleCall
   public void transformTo(RelNode rel, Map equiv,
   RelHintsPropagator handler) {
+if (rel instanceof PhysicalNode
+&& rule instanceof TransformationRule) {
+  throw new RuntimeException(
+  rel + " is a PhysicalNode, which is not allowed in " + rule);
+}
+
 rel = handler.propagate(rels[0], rel);
 if (LOGGER.isDebugEnabled()) {
   LOGGER.debug("Transform to: rel#{} via {}{}", rel.getId(), getRule(),
@@ -136,7 +144,9 @@ public class VolcanoRuleCall extends RelOptRuleCall {
 volcanoPlanner.ensureRegistered(
 entry.getKey(), entry.getValue());
   }
-  volcanoPlanner.ensureRegistered(rel, rels[0]);
+  // The subset is not used, but we need it, just for debugging
+  //noinspection unused
+  RelSubset subset = volcanoPlanner.ensureRegistered(rel, rels[0]);
   rels[0].getCluster().invalidateMetadataQuery();
 
   if (volcanoPlanner.getListener() != null) {
@@ -349,6 +359,10 @@ public class VolcanoRuleCall extends RelOptRuleCall {
   }
 
   for (RelNode rel : successors) {
+if (operand.getRule() instanceof TransformationRule
+&& rel.getConvention() != previous.getConvention()) {
+  continue;
+}
 if (!operand.matches(rel)) {
   continue;
 }
diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectRemoveRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectRemoveRule.java
index ba8ff2e..b1e935b 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/ProjectRemoveRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/ProjectRemoveRule.java
@@ -66,6 +66,7 @@ public class ProjectRemoveRule extends RelOptRule implements 
SubstitutionRule {
   childProject.getInput(), childProject.getProjects(),
   project.getRowType());
 }
+stripped = convert(stripped, project.getConvention());
 call.transformTo(stripped);
   }
 
diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveRule.java
index 860e666..1d71ea4 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/SortRemoveRule.java
@@ -61,7 +61,8 @@ public class SortRemoveRule extends RelOptRule implements 
TransformationRule {
 final RelCollation collation = sort.getCollation();
 assert collation == sort.getTraitSet()
 .getTrait(RelCollationTraitDef.INSTANCE);
-final RelTraitSet traits = 
sort.getInput().getTraitSet().replace(collation);
+final RelTraitSet traits = sort.getInput().getTraitSet()
+.replace(collation).replace(sort.getConvention());
 call.transformTo(convert(sort.getInput(), traits));
   }
 }
diff --git a/site/_docs/history.md b/site/_docs/history.md
index b769b48..f21942f 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -34,6 +34,8 @@ Downloads are available on the
 
 * [https://issues.apache.org/jira/browse/CALCITE-4032;&

[calcite] branch master updated: Reformat test output xml file

2020-06-08 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 d98f6c7  Reformat test output xml file
d98f6c7 is described below

commit d98f6c7b1fb2d71133b606b2f178ee80f39525b4
Author: Haisheng Yuan 
AuthorDate: Mon Jun 8 20:40:31 2020 -0500

Reformat test output xml file
---
 .../org/apache/calcite/test/TopDownOptTest.java|   4 +-
 .../org/apache/calcite/test/TopDownOptTest.xml | 854 ++---
 2 files changed, 407 insertions(+), 451 deletions(-)

diff --git a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java 
b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
index ce73180..6b6ceb6 100644
--- a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
+++ b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
@@ -56,13 +56,13 @@ import java.util.List;
  * for details on the schema.
  *
  * Run the test. It should fail. Inspect the output in
- * {@code target/surefire/.../TopDownOptTest.xml}.
+ * {@code build/resources/test/.../TopDownOptTest_actual.xml}.
  *
  * Verify that the "planBefore" is the correct
  * translation of your SQL, and that it contains the pattern on which your rule
  * is supposed to fire. If all is well, replace
  * {@code src/test/resources/.../TopDownOptTest.xml} and
- * with the new {@code target/surefire/.../TopDownOptTest.xml}.
+ * with the new {@code build/resources/test/.../TopDownOptTest_actual.xml}.
  *
  * Run the test again. It should fail again, but this time it should 
contain
  * a "planAfter" entry for your rule. Verify that your rule applied its
diff --git a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml 
b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
index e151e29..8dc333c 100644
--- a/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/TopDownOptTest.xml
@@ -16,65 +16,63 @@
   ~ limitations under the License.
   -->
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
-
-
-
-
-
-
+
+
+  
-
-
-
-
-
+
+  
   
 
   
+group by mgr,deptno,comm
+order by comm desc nulls last, deptno nulls first]]>
 
 
   
+sales.emp r join sales.bonus s on r.ename=s.ename and r.job=s.job
+order by r.job desc nulls last, r.ename nulls first]]>
 
 
   
+sales.emp r join sales.bonus s on r.ename=s.ename and r.job=s.job
+order by s.job desc nulls last, s.ename nulls first]]>
 
 
   
+(select ename, job, max(sal) from sales.emp group by ename, job) r
+join sales.bonus s on r.job=s.job and r.ename=s.ename]]>
 
 
   
+(select ename, job, mgr, max(sal) from sales.emp group by ename, job, mgr) r
+join sales.bonus s

[calcite] branch master updated: [CALCITE-4041] Support trait propagation for EnumerableCorrelate

2020-06-08 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 61cf2bf  [CALCITE-4041] Support trait propagation for 
EnumerableCorrelate
61cf2bf is described below

commit 61cf2bf30d0496cf795fd0f5d4cf9dc9f468c9b5
Author: rubenada 
AuthorDate: Fri Jun 5 14:45:31 2020 +0200

[CALCITE-4041] Support trait propagation for EnumerableCorrelate

Close #2005
---
 .../adapter/enumerable/EnumerableCorrelate.java|  49 +
 .../org/apache/calcite/test/TopDownOptTest.java|  68 
 .../org/apache/calcite/test/TopDownOptTest.xml | 120 +
 3 files changed, 237 insertions(+)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
index aa30f14..cc1e56c 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
@@ -21,9 +21,13 @@ import org.apache.calcite.linq4j.tree.Expression;
 import org.apache.calcite.linq4j.tree.Expressions;
 import org.apache.calcite.linq4j.tree.ParameterExpression;
 import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelCollationTraitDef;
+import org.apache.calcite.rel.RelCollations;
+import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Correlate;
 import org.apache.calcite.rel.core.CorrelationId;
@@ -32,11 +36,13 @@ import org.apache.calcite.rel.metadata.RelMdCollation;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
 import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableBitSet;
+import org.apache.calcite.util.Pair;
 
 import com.google.common.collect.ImmutableList;
 
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
+import java.util.List;
 
 /** Implementation of {@link org.apache.calcite.rel.core.Correlate} in
  * {@link org.apache.calcite.adapter.enumerable.EnumerableConvention 
enumerable calling convention}. */
@@ -81,6 +87,49 @@ public class EnumerableCorrelate extends Correlate
 traitSet, left, right, correlationId, requiredColumns, joinType);
   }
 
+  @Override public Pair> passThroughTraits(
+  final RelTraitSet required) {
+final RelCollation collation = required.getCollation();
+if (collation == null || collation == RelCollations.EMPTY) {
+  return null;
+}
+
+// EnumerableCorrelate traits passdown shall only pass through collation 
to left input.
+// This is because for EnumerableCorrelate always uses left input as the 
outer loop,
+// thus only left input can preserve ordering.
+
+for (RelFieldCollation relFieldCollation : collation.getFieldCollations()) 
{
+  // If field collation belongs to right input: bail out.
+  if (relFieldCollation.getFieldIndex() >= 
getLeft().getRowType().getFieldCount()) {
+return null;
+  }
+}
+
+final RelTraitSet passThroughTraitSet = traitSet.replace(collation);
+return Pair.of(passThroughTraitSet,
+ImmutableList.of(
+passThroughTraitSet,
+passThroughTraitSet.replace(RelCollations.EMPTY)));
+  }
+
+  @Override public Pair> deriveTraits(
+  final RelTraitSet childTraits, final int childId) {
+// should only derive traits (limited to collation for now) from left 
input.
+assert childId == 0;
+
+final RelCollation collation = childTraits.getCollation();
+if (collation == null || collation == RelCollations.EMPTY) {
+  return null;
+}
+
+final RelTraitSet traits = traitSet.replace(collation);
+return Pair.of(traits, ImmutableList.of(traits, right.getTraitSet()));
+  }
+
+  @Override public DeriveMode getDeriveMode() {
+return DeriveMode.LEFT_FIRST;
+  }
+
   public Result implement(EnumerableRelImplementor implementor,
   Prefer pref) {
 final BlockBuilder builder = new BlockBuilder();
diff --git a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java 
b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
index fdac1d3..ce73180 100644
--- a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
+++ b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
@@ -25,6 +25,8 @@ import org.apache.calcite.plan.volcano.VolcanoPlanner;
 import org.apache.calcite.rel.RelCollationTraitDef;
 import org.apache.calcite.rel.rules.JoinCommuteRule;
 import org.apache.calcite.rel.rules.JoinPushThroughJoinRule

[calcite] branch master updated: [CALCITE-4007] MergeJoin collation check should not be limited to join key's order

2020-06-08 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 dcc76ce  [CALCITE-4007] MergeJoin collation check should not be 
limited to join key's order
dcc76ce is described below

commit dcc76cede53c7971bc9c3755d9261e766aa63b66
Author: Haisheng Yuan 
AuthorDate: Sun May 31 12:00:32 2020 -0500

[CALCITE-4007] MergeJoin collation check should not be limited to join 
key's order

Given MergeJoin on foo.a=bar.a and foo.b=bar.b,
The collation check on MergeJoin always require it is sorted by (a,b), but
after 1.23.0 calcite can generate MergeJoin on collation of (b,a), or even
(a,b,c), (b,a,c), which are all legit. We should relax the check condition.

This also fixed CALCITE-4050.

Close #2010
---
 .../adapter/enumerable/EnumerableMergeJoin.java| 102 +
 .../java/org/apache/calcite/rel/RelCollation.java  |   2 +-
 .../java/org/apache/calcite/rel/RelCollations.java |  36 
 .../calcite/rel/metadata/RelMdCollation.java   |   4 -
 .../org/apache/calcite/util/ImmutableIntList.java  |  12 +++
 .../org/apache/calcite/rel/RelCollationTest.java   |  16 
 .../apache/calcite/test/SqlHintsConverterTest.java |   7 +-
 .../apache/calcite/test/SqlHintsConverterTest.xml  |   6 +-
 8 files changed, 140 insertions(+), 45 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java
index 4105682..f9f4d1a 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java
@@ -44,6 +44,7 @@ import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.ImmutableIntList;
 import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 import org.apache.calcite.util.mapping.Mappings;
 
 import com.google.common.collect.ImmutableList;
@@ -69,6 +70,39 @@ public class EnumerableMergeJoin extends Join implements 
EnumerableRel {
   Set variablesSet,
   JoinRelType joinType) {
 super(cluster, traits, ImmutableList.of(), left, right, condition, 
variablesSet, joinType);
+final List leftCollations =
+left.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
+final List rightCollations =
+right.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
+
+// If the join keys are not distinct, the sanity check doesn't apply.
+// e.g. t1.a=t2.b and t1.a=t2.c
+boolean isDistinct = Util.isDistinct(joinInfo.leftKeys)
+&& Util.isDistinct(joinInfo.rightKeys);
+
+if (!RelCollations.containsOrderless(leftCollations, joinInfo.leftKeys)
+|| !RelCollations.containsOrderless(rightCollations, 
joinInfo.rightKeys)) {
+  if (isDistinct) {
+throw new RuntimeException("wrong collation in left or right input");
+  }
+}
+
+final List collations =
+traits.getTraits(RelCollationTraitDef.INSTANCE);
+assert collations != null && collations.size() > 0;
+ImmutableIntList rightKeys = joinInfo.rightKeys
+.incr(left.getRowType().getFieldCount());
+// Currently it has very limited ability to represent the equivalent traits
+// due to the flaw of RelCompositeTrait, so the following case is totally
+// legit, but not yet supported:
+// SELECT * FROM foo JOIN bar ON foo.a = bar.c AND foo.b = bar.d;
+// MergeJoin has collation on [a, d], or [b, c]
+if (!RelCollations.containsOrderless(collations, joinInfo.leftKeys)
+&& !RelCollations.containsOrderless(collations, rightKeys)) {
+  if (isDistinct) {
+throw new RuntimeException("wrong collation for mergejoin");
+  }
+}
 if (!isMergeJoinSupported(joinType)) {
   throw new UnsupportedOperationException(
   "EnumerableMergeJoin unsupported for join type " + joinType);
@@ -107,26 +141,18 @@ public class EnumerableMergeJoin extends Join implements 
EnumerableRel {
 ImmutableBitSet rightKeySet = ImmutableBitSet.of(joinInfo.rightKeys)
 .shift(left.getRowType().getFieldCount());
 
-Map keyMap = new HashMap<>();
-final int keyCount = leftKeySet.cardinality();
-for (int i = 0; i < keyCount; i++) {
-  keyMap.put(joinInfo.leftKeys.get(i), joinInfo.rightKeys.get(i));
-}
-Mappings.TargetMapping mapping = Mappings.target(keyMap,
-left.getRowType().getFieldCount(),
-right.getRowType().getFieldCount());
-
 // Only consider exact key match for now
 if (reqKeySet.equals(leftKeySet)) {
-  RelCollation rightCollation = RexUtil.apply(mapping, col

[calcite] branch master updated: [CALCITE-4012] Support trait propagation for EnumerableHashJoin and EnumerableNestedLoopJoin (Rui Wang)

2020-06-08 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 eedd40b  [CALCITE-4012] Support trait propagation for 
EnumerableHashJoin and EnumerableNestedLoopJoin (Rui Wang)
eedd40b is described below

commit eedd40bea825e0a00f5e463dd1f10c94eb233750
Author: amaliujia 
AuthorDate: Sun May 31 02:16:55 2020 -0700

[CALCITE-4012] Support trait propagation for EnumerableHashJoin and 
EnumerableNestedLoopJoin (Rui Wang)

Both EnumerableHashJoin and EnumerableNestedLoopJoin can pass down 
collation to
left input, and cannot push it down to right input, because
1) EnumerableHashJoin always builds hash table on right input.
2) EnumerableNestedLoopJoin always use left input as outer loop.

Thus only left input can preserve ordering. Similarly, both 
EnumerableHashJoin
and EnumerableNestedLoopJoin can only derive collation from left input. In
top-down opt, traits propagation is supposed to replace 
SortJoinTransposeRule
and SortJoinCopyRule.

Close #1995
---
 .../adapter/enumerable/EnumerableHashJoin.java |  54 +++
 .../adapter/enumerable/EnumerableMergeJoin.java|   4 +-
 .../enumerable/EnumerableNestedLoopJoin.java   |  62 +++
 .../enumerable/EnumerableSortedAggregate.java  |   3 +-
 .../org/apache/calcite/test/TopDownOptTest.java| 222 ++
 .../org/apache/calcite/test/TopDownOptTest.xml | 468 +
 6 files changed, 809 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
index a7a8ede..aa2f41f 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java
@@ -19,11 +19,15 @@ package org.apache.calcite.adapter.enumerable;
 import org.apache.calcite.linq4j.tree.BlockBuilder;
 import org.apache.calcite.linq4j.tree.Expression;
 import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.plan.DeriveMode;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptCost;
 import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelCollationTraitDef;
+import org.apache.calcite.rel.RelCollations;
+import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.RelNodes;
 import org.apache.calcite.rel.core.CorrelationId;
@@ -36,11 +40,13 @@ import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexUtil;
 import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableIntList;
+import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 
 import com.google.common.collect.ImmutableList;
 
 import java.lang.reflect.Method;
+import java.util.List;
 import java.util.Set;
 
 /** Implementation of {@link org.apache.calcite.rel.core.Join} in
@@ -100,6 +106,54 @@ public class EnumerableHashJoin extends Join implements 
EnumerableRel {
 condition, variablesSet, joinType);
   }
 
+  @Override public Pair> passThroughTraits(
+  final RelTraitSet required) {
+RelCollation collation = required.getCollation();
+if (collation == null
+|| collation == RelCollations.EMPTY
+|| joinType == JoinRelType.FULL
+|| joinType == JoinRelType.RIGHT) {
+  return null;
+}
+
+for (RelFieldCollation fc : collation.getFieldCollations()) {
+  // If field collation belongs to right input: cannot push down collation.
+  if (fc.getFieldIndex() >= getLeft().getRowType().getFieldCount()) {
+return null;
+  }
+}
+
+RelTraitSet passthroughTraitSet = traitSet.replace(collation);
+return Pair.of(passthroughTraitSet,
+ImmutableList.of(
+passthroughTraitSet,
+passthroughTraitSet.replace(RelCollations.EMPTY)));
+  }
+
+  @Override public Pair> deriveTraits(
+  final RelTraitSet childTraits, final int childId) {
+// should only derive traits (limited to collation for now) from left join 
input.
+assert childId == 0;
+
+RelCollation collation = childTraits.getCollation();
+if (collation == null || collation == RelCollations.EMPTY) {
+  return null;
+}
+
+RelTraitSet derivedTraits = getTraitSet().replace(collation);
+return Pair.of(
+derivedTraits,
+ImmutableList.of(derivedTraits, right.getTraitSet()));
+  }
+
+  @Override public DeriveMode getDeriveMode() {
+if (joinType == JoinRelType.FULL || joinType == JoinRelType.RIGHT) {
+  return DeriveMode.PROHIBITED;
+}
+
+ 

[calcite] branch master updated (721ac8c -> feae6fb)

2020-06-04 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 721ac8c  [CALCITE-4042] JoinCommuteRule must not match SEMI / ANTI join
 add feae6fb  [CALCITE-4030] Reinstate assertion check for trait derivation 
in OptimizeTask

No new revisions were added by this update.

Summary of changes:
 .../src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



[calcite] branch master updated (721ac8c -> feae6fb)

2020-06-04 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 721ac8c  [CALCITE-4042] JoinCommuteRule must not match SEMI / ANTI join
 add feae6fb  [CALCITE-4030] Reinstate assertion check for trait derivation 
in OptimizeTask

No new revisions were added by this update.

Summary of changes:
 .../src/main/java/org/apache/calcite/plan/volcano/OptimizeTask.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



[calcite] branch master updated: [CALCITE-3991] The required should always be provided in RelSet.getOrCreateSubset() (Botong Huang)

2020-06-03 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 2f68352  [CALCITE-3991] The required should always be provided in 
RelSet.getOrCreateSubset() (Botong Huang)
2f68352 is described below

commit 2f68352c6dc9d05c6cb71516dac1105c27722154
Author: botong.huang 
AuthorDate: Mon May 11 15:19:01 2020 -0700

[CALCITE-3991] The required should always be provided in 
RelSet.getOrCreateSubset() (Botong Huang)

Close #2001
---
 .../java/org/apache/calcite/plan/volcano/RelSet.java |  4 
 .../org/apache/calcite/plan/volcano/RelSubset.java   |  2 +-
 .../apache/calcite/plan/volcano/VolcanoPlanner.java  | 20 +++-
 3 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
index 4aeec2a..09e6f37 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/RelSet.java
@@ -282,10 +282,6 @@ class RelSet {
 }
   }
 
-  RelSubset getOrCreateSubset(RelOptCluster cluster, RelTraitSet traits) {
-return getOrCreateSubset(cluster, traits, false);
-  }
-
   RelSubset getOrCreateSubset(
   RelOptCluster cluster, RelTraitSet traits, boolean required) {
 boolean needsConverter = false;
diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
index ad37268..8b0a78a 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
@@ -194,7 +194,7 @@ public class RelSubset extends AbstractRelNode {
   if (traitSet1.equals(this.traitSet)) {
 return this;
   }
-  return set.getOrCreateSubset(getCluster(), traitSet1);
+  return set.getOrCreateSubset(getCluster(), traitSet1, isRequired());
 }
 throw new UnsupportedOperationException();
   }
diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
index d7dcd5f..8374f1b 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
@@ -773,16 +773,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner {
 }
   }
 
-  public RelSubset getSubset(
-  RelNode rel,
-  RelTraitSet traits) {
-return getSubset(rel, traits, false);
-  }
-
-  public RelSubset getSubset(
-  RelNode rel,
-  RelTraitSet traits,
-  boolean createIfMissing) {
+  public RelSubset getSubset(RelNode rel, RelTraitSet traits) {
 if ((rel instanceof RelSubset) && (rel.getTraitSet().equals(traits))) {
   return (RelSubset) rel;
 }
@@ -790,9 +781,6 @@ public class VolcanoPlanner extends AbstractRelOptPlanner {
 if (set == null) {
   return null;
 }
-if (createIfMissing) {
-  return set.getOrCreateSubset(rel.getCluster(), traits);
-}
 return set.getSubset(traits);
   }
 
@@ -1097,10 +1085,8 @@ public class VolcanoPlanner extends 
AbstractRelOptPlanner {
 // Was the set we merged with the root? If so, the result is the new
 // root.
 if (set2 == getSet(root)) {
-  root =
-  set.getOrCreateSubset(
-  root.getCluster(),
-  root.getTraitSet());
+  root = set.getOrCreateSubset(
+  root.getCluster(), root.getTraitSet(), root.isRequired());
   ensureRootConverters();
 }
 



[calcite] branch master updated: [CALCITE-3981] Volcano.register should not return stale subset (Botong Huang)

2020-06-03 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 df5f447  [CALCITE-3981] Volcano.register should not return stale 
subset (Botong Huang)
df5f447 is described below

commit df5f4470e4257e8e7057664d4af3af3f37b6559b
Author: botong.huang 
AuthorDate: Sat Apr 18 22:15:30 2020 -0700

[CALCITE-3981] Volcano.register should not return stale subset (Botong 
Huang)

When a subset is registered, registerImpl() and registerSubset() currently
simply returns the subset itself. The problem is that subset can become 
stale
when relSets get merged (for example in ensureRegistered() and 
registerSubset()
"merge(set, subset.set)"). As a result, a stale subset might be returned 
from
registerImpl, and the newly registering subtree might get registered
recursively on top of the stale subset (see AbstractRelNode.onRegister()). 
This
is a leak because once a relSet is merged into others and becomes stale, it
should not be used to connect new relNodes.

With CALCITE-3755, subsets can now be directly matched by rules. This opens
another source of stale subset leak: (1) An active subset gets matched, the
RuleMatch gets queued in RuleQueue. (2) The subset becomes stale due to 
relSet
merge. (3) The rule match in (1) is popped from queue and fired. (4) In 
OnMatch
the rule gets the stale subset, builds new rels on top of it and regsiter 
the
new rels. In this case, the entire new rel subtree will be registered on 
top of
the stale subset as is.

Close #1966
---
 .../main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java  | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
index 90030d0..d7dcd5f 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
@@ -628,6 +628,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner {
   "equivRel rowtype",
   equivRel.getRowType(),
   Litmus.THROW);
+  equivRel = ensureRegistered(equivRel, null);
   set = getSet(equivRel);
 }
 return registerImpl(rel, set);
@@ -643,7 +644,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner {
   merge(equivSubset.set, subset.set);
 }
   }
-  result = subset;
+  result = canonize(subset);
 } else {
   result = register(rel, equivRel);
 }
@@ -1024,7 +1025,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner 
{
   set = set.equivalentSet;
 } while (set.equivalentSet != null);
 return set.getOrCreateSubset(
-subset.getCluster(), subset.getTraitSet());
+subset.getCluster(), subset.getTraitSet(), subset.isRequired());
   }
 
   /**
@@ -1331,7 +1332,7 @@ public class VolcanoPlanner extends AbstractRelOptPlanner 
{
   LOGGER.trace("Register #{} {}, and merge sets", subset.getId(), subset);
   merge(set, subset.set);
 }
-return subset;
+return canonize(subset);
   }
 
   // implement RelOptPlanner



[calcite] branch master updated: [CALCITE-4032] Mark CalcMergeRule as TransformationRule

2020-06-02 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 29f798f  [CALCITE-4032] Mark CalcMergeRule as TransformationRule
29f798f is described below

commit 29f798fb6919f24d95776658b7e659af179a8b15
Author: Haisheng Yuan 
AuthorDate: Sun May 31 12:02:09 2020 -0500

[CALCITE-4032] Mark CalcMergeRule as TransformationRule

So that in VolcanoPlanner, CalcMergeRule doesn't match EnumerableCalc 
anymore.
It only matches LogicalCalc.

Close #1997
---
 core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java | 2 +-
 site/_docs/history.md  | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
index fc4a2e8..a65f81e 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
@@ -35,7 +35,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
  * {@link org.apache.calcite.rel.logical.LogicalCalc}, but expressed in terms 
of
  * the lower {@link org.apache.calcite.rel.logical.LogicalCalc}'s inputs.
  */
-public class CalcMergeRule extends RelOptRule {
+public class CalcMergeRule extends RelOptRule implements TransformationRule {
   //~ Static fields/initializers -
 
   public static final CalcMergeRule INSTANCE =
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 7e40ae4..b769b48 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -27,6 +27,13 @@ For a full list of releases, see
 https://github.com/apache/calcite/releases;>github.
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
+## https://github.com/apache/calcite/releases/tag/calcite-1.24.0;>1.24.0 
/ under development
+{: #v1-24-0}
+
+ Breaking Changes
+
+* [https://issues.apache.org/jira/browse/CALCITE-4032;>CALCITE-4032]
+  Mark `CalcMergeRule` as `TransformationRule`
 
 ## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-23
 {: #v1-23-0}



[calcite] branch master updated: [CALCITE-4023] Deprecate ProjectSortTransposeRule

2020-05-31 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 2fb963c  [CALCITE-4023] Deprecate ProjectSortTransposeRule
2fb963c is described below

commit 2fb963c139abc7f655e237c78157f2e4983c4709
Author: Haisheng Yuan 
AuthorDate: Fri May 29 23:09:55 2020 -0500

[CALCITE-4023] Deprecate ProjectSortTransposeRule
---
 .../java/org/apache/calcite/rel/rules/ProjectSortTransposeRule.java| 1 +
 core/src/test/java/org/apache/calcite/test/TopDownOptTest.java | 2 --
 druid/src/main/java/org/apache/calcite/adapter/druid/DruidRules.java   | 3 ++-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectSortTransposeRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectSortTransposeRule.java
index e380db3..787d52f 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectSortTransposeRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectSortTransposeRule.java
@@ -34,6 +34,7 @@ import com.google.common.collect.ImmutableList;
  *
  * @see org.apache.calcite.rel.rules.SortProjectTransposeRule
  */
+@Deprecated // to be removed before 1.25
 public class ProjectSortTransposeRule extends RelOptRule implements 
TransformationRule {
   public static final ProjectSortTransposeRule INSTANCE =
   new ProjectSortTransposeRule(Project.class, Sort.class,
diff --git a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java 
b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
index 592661a..7f40f08 100644
--- a/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
+++ b/core/src/test/java/org/apache/calcite/test/TopDownOptTest.java
@@ -25,7 +25,6 @@ import org.apache.calcite.plan.volcano.VolcanoPlanner;
 import org.apache.calcite.rel.RelCollationTraitDef;
 import org.apache.calcite.rel.rules.JoinCommuteRule;
 import org.apache.calcite.rel.rules.JoinPushThroughJoinRule;
-import org.apache.calcite.rel.rules.ProjectSortTransposeRule;
 import org.apache.calcite.rel.rules.SortProjectTransposeRule;
 
 import com.google.common.collect.ImmutableList;
@@ -324,7 +323,6 @@ class Query extends RelOptTestBase {
 
 // pushing down sort should be handled by top-down optimization.
 planner.removeRule(SortProjectTransposeRule.INSTANCE);
-planner.removeRule(ProjectSortTransposeRule.INSTANCE);
   }
 
   public static Query create(String sql) {
diff --git 
a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidRules.java 
b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidRules.java
index e966e5b..3e51f58 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidRules.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidRules.java
@@ -91,6 +91,7 @@ public class DruidRules {
   new DruidSortRule(RelFactories.LOGICAL_BUILDER);
   public static final DruidSortProjectTransposeRule SORT_PROJECT_TRANSPOSE =
   new DruidSortProjectTransposeRule(RelFactories.LOGICAL_BUILDER);
+  @Deprecated // to be removed before 1.25
   public static final DruidProjectSortTransposeRule PROJECT_SORT_TRANSPOSE =
   new DruidProjectSortTransposeRule(RelFactories.LOGICAL_BUILDER);
   public static final DruidProjectFilterTransposeRule PROJECT_FILTER_TRANSPOSE 
=
@@ -119,7 +120,6 @@ public class DruidRules {
   AGGREGATE,
   FILTER_AGGREGATE_TRANSPOSE,
   FILTER_PROJECT_TRANSPOSE,
-  PROJECT_SORT_TRANSPOSE,
   SORT,
   SORT_PROJECT_TRANSPOSE,
   DRUID_HAVING_FILTER_RULE);
@@ -730,6 +730,7 @@ public class DruidRules {
* {@link org.apache.calcite.rel.core.Sort}. Useful if after pushing Sort,
* we could not push it inside DruidQuery.
*/
+  @Deprecated // to be removed before 1.25
   public static class DruidProjectSortTransposeRule
   extends ProjectSortTransposeRule {
 



[calcite] branch master updated: [CALCITE-3993] Add utility methods to RelTrait, RelTraitSet and RelCollation

2020-05-29 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 af976e9  [CALCITE-3993] Add utility methods to RelTrait, RelTraitSet 
and RelCollation
af976e9 is described below

commit af976e9d4caa9588db8e413a58468760f3c1c0d6
Author: Haisheng Yuan 
AuthorDate: Tue May 12 23:17:40 2020 -0500

[CALCITE-3993] Add utility methods to RelTrait, RelTraitSet and RelCollation

Close #1973
---
 .../java/org/apache/calcite/plan/RelTrait.java | 24 -
 .../java/org/apache/calcite/plan/RelTraitSet.java  | 42 ++
 .../org/apache/calcite/plan/volcano/RelSet.java|  2 +-
 .../java/org/apache/calcite/rel/RelCollation.java  | 17 -
 4 files changed, 68 insertions(+), 17 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/plan/RelTrait.java 
b/core/src/main/java/org/apache/calcite/plan/RelTrait.java
index aa98827..37440a2 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTrait.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTrait.java
@@ -93,16 +93,17 @@ public interface RelTrait {
   /**
* Applies a mapping to this trait.
*
-   * Some traits may be changed if the columns order is changed by a 
mapping of the
-   * {@link Project} operator. 
+   * Some traits may be changed if the columns order is changed by a mapping
+   * of the {@link Project} operator. 
*
-   * For example, if relation {@code SELECT a, b ORDER BY a, b} is sorted 
by columns [0, 1],
-   * then the project {@code SELECT b, a} over this relation will be sorted by 
columns [1, 0].
-   * In the same time project {@code SELECT b} will not be sorted at all 
because it doesn't
-   * contain the collation prefix and this method will return an empty 
collation. 
+   * For example, if relation {@code SELECT a, b ORDER BY a, b} is sorted by
+   * columns [0, 1], then the project {@code SELECT b, a} over this relation
+   * will be sorted by columns [1, 0]. In the same time project {@code SELECT 
b}
+   * will not be sorted at all because it doesn't contain the collation
+   * prefix and this method will return an empty collation. 
*
-   * Other traits are independent from the columns remapping. For example 
{@link Convention} or
-   * {@link RelDistributions#SINGLETON}.
+   * Other traits are independent from the columns remapping. For example
+   * {@link Convention} or {@link RelDistributions#SINGLETON}.
*
* @param mapping   Mapping
* @return trait with mapping applied
@@ -110,4 +111,11 @@ public interface RelTrait {
   default  T apply(Mappings.TargetMapping mapping) {
 return (T) this;
   }
+
+  /**
+   * Returns whether this trait is the default trait value.
+   */
+  default boolean isDefault() {
+return this == getTraitDef().getDefault();
+  }
 }
diff --git a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java 
b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
index 09fb10a..c521968 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelTraitSet.java
@@ -43,6 +43,8 @@ public final class RelTraitSet extends AbstractList 
{
   private final Cache cache;
   private final RelTrait[] traits;
   private final String string;
+  /** Cache the hash code for the traits */
+  private int hash = 0;
 
   //~ Constructors ---
 
@@ -308,7 +310,8 @@ public final class RelTraitSet extends 
AbstractList {
   if (traits[i].getTraitDef() == ConventionTraitDef.INSTANCE) {
 continue;
   }
-  if (!traits[i].equals(other.traits[i])) {
+  // each trait should be canonized already
+  if (traits[i] != other.traits[i]) {
 return false;
   }
 }
@@ -417,13 +420,34 @@ public final class RelTraitSet extends 
AbstractList {
* @return true if traits are equal and in the same order, false otherwise
*/
   @Override public boolean equals(Object obj) {
-return this == obj
-|| obj instanceof RelTraitSet
-&& Arrays.equals(traits, ((RelTraitSet) obj).traits);
+if (this == obj) {
+  return true;
+}
+if (!(obj instanceof RelTraitSet)) {
+  return false;
+}
+RelTraitSet that = (RelTraitSet) obj;
+if (this.hash != 0
+&& that.hash != 0
+&& this.hash != that.hash) {
+  return false;
+}
+if (traits.length != that.traits.length) {
+  return false;
+}
+for (int i = 0; i < traits.length; i++) {
+  if (traits[i] != that.traits[i]) {
+return false;
+  }
+}
+return true;
   }
 
   @Override public int hashCode() {
-return Arrays.hashCode(traits);
+if (hash == 0) {
+  hash = Arrays.hashCode(traits);
+}
+return hash;
   }
 
   /**
@@ -690,8 +714,12 @@ pub

[calcite] branch master updated: [CALCITE-4011] Support trait propagation for EnumerableProject and EnumerableFilter (Rui Wang)

2020-05-29 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 0af3fd1  [CALCITE-4011] Support trait propagation for 
EnumerableProject and EnumerableFilter (Rui Wang)
0af3fd1 is described below

commit 0af3fd17a293d37125c7cca58257e5f6cbc1a76c
Author: amaliujia 
AuthorDate: Tue May 19 23:52:40 2020 -0700

[CALCITE-4011] Support trait propagation for EnumerableProject and 
EnumerableFilter (Rui Wang)

Trait propgation includes trait passthrough and trait derivation.

Trait passthrough could happen when Project satisfies the ordering
requirement that is defined by collations. Project will not satisfy the
ordering requirement when a requested collation is defined on a
non-trivial expression. Usually a RexCall is considered as non-trivial,
unless it is a CAST that perserves monotonicity,

Here is an example to demonstrate why trait cannot pass through when
collations are defined on non-trival expr:

select a, b*-1 as b
from foo
order by a, b;

which generates the logical plan:
LogicalSort
  LogicalProject
 LogicalTableScan

We cannot move the top sort down through the project. Because b*-1 will
change ordering to the opposite. The sort has to remain on top of
project for correness.

Trait derivaiton does something simlar to trait pass through, except for
one difference:
trait derivation can return parital collations that are derived from
child. For example, if [a, b, c, d] is derived from child, and if c is
defined on a non-trival expr, then [a, b] will be returned cause it
might be useful for parents.

Another example to show why trait derivation could be useful to reutrn
partial collations:

select a, b
from (
 select a, b, c*-1, d
 from foo
 order by a, b, c, d
)
order by a, b;

In this example, even though the inner project does not preserve the
total ordering for inner sort, but the outer sort only want to sort on
[a, b], thus if inner project can derive [a, b], the outer project will
not need the top sort or enforce a sort for its input.

After top-down optimization is enabled, trait propagation for 
EnumerableProject
and EnumerableFilter is supposed to replace ProjectSortTransposeRule and
SortProjectTransposeRule.

Close #1985
---
 .../adapter/enumerable/EnumerableConvention.java   |   7 +-
 .../adapter/enumerable/EnumerableFilter.java   |  27 ++
 .../adapter/enumerable/EnumerableMergeJoin.java|   2 +-
 .../adapter/enumerable/EnumerableProject.java  | 114 ++
 .../calcite/config/CalciteConnectionConfig.java|   2 +
 .../config/CalciteConnectionConfigImpl.java|   4 +
 .../calcite/config/CalciteConnectionProperty.java  |   5 +-
 .../calcite/config/CalciteSystemProperty.java  |   3 +-
 .../apache/calcite/plan/volcano/OptimizeTask.java  |   3 +-
 .../apache/calcite/prepare/CalcitePrepareImpl.java |   1 +
 .../org/apache/calcite/test/TopDownOptTest.java| 293 --
 .../java/org/apache/calcite/tools/PlannerTest.java |  31 +-
 .../org/apache/calcite/test/TopDownOptTest.xml | 429 +
 core/src/test/resources/saffron.properties |   2 +-
 .../apache/calcite/adapter/tpcds/TpcdsTest.java|  50 ++-
 15 files changed, 877 insertions(+), 96 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
index 48ae551..6acc25d 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
@@ -24,7 +24,7 @@ import org.apache.calcite.plan.RelTrait;
 import org.apache.calcite.plan.RelTraitDef;
 import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelCollation;
-import org.apache.calcite.rel.RelCollationTraitDef;
+import org.apache.calcite.rel.RelCollations;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.RelFactories;
 
@@ -60,9 +60,8 @@ public enum EnumerableConvention implements Convention {
   input.getCluster().getPlanner(),
   input, INSTANCE, true);
 }
-RelCollation collation = required.getTrait(RelCollationTraitDef.INSTANCE);
-if (collation != null) {
-  assert !collation.getFieldCollations().isEmpty();
+RelCollation collation = required.getCollation();
+if (collation != null && collation != RelCollations.EMPTY) {
   rel = EnumerableSort.create(rel, collation, null, null);
 }
 return rel;
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableFilter.

[calcite] branch master updated: [CALCITE-3972] Allow RelBuilder to create RelNode with convention (Xiening Dai)

2020-05-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 ada6cc4  [CALCITE-3972] Allow RelBuilder to create RelNode with 
convention (Xiening Dai)
ada6cc4 is described below

commit ada6cc4309dd79e09abcbd67570b786d80340018
Author: Xiening Dai 
AuthorDate: Tue Mar 24 16:29:57 2020 -0700

[CALCITE-3972] Allow RelBuilder to create RelNode with convention (Xiening 
Dai)

1. Provide Convention.transformRelBuilder() to transform an existing 
RelBuilder
into one with specific convention.
2. RelBuilder provides withRelFactories() method to allow caller swap the
underlying RelFactories and create a new builder.
We can avoid ~1/3 of total rule firings in a N way join case with this 
change.

Close #1884
---
 .../adapter/enumerable/EnumerableConvention.java   |  11 +++
 .../adapter/enumerable/EnumerableRelFactories.java | 102 +
 .../apache/calcite/plan/AbstractRelOptPlanner.java |  10 ++
 .../java/org/apache/calcite/plan/Convention.java   |   8 ++
 .../calcite/rel/rules/JoinPushThroughJoinRule.java |   2 +-
 .../java/org/apache/calcite/tools/RelBuilder.java  |  18 +++-
 .../org/apache/calcite/test/RelBuilderTest.java|  39 
 site/_docs/algebra.md  |  15 +++
 8 files changed, 203 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
index 5b583da..48ae551 100644
--- 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableConvention.java
@@ -16,6 +16,7 @@
  */
 package org.apache.calcite.adapter.enumerable;
 
+import org.apache.calcite.plan.Contexts;
 import org.apache.calcite.plan.Convention;
 import org.apache.calcite.plan.ConventionTraitDef;
 import org.apache.calcite.plan.RelOptPlanner;
@@ -25,6 +26,7 @@ import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelCollation;
 import org.apache.calcite.rel.RelCollationTraitDef;
 import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.RelFactories;
 
 /**
  * Family of calling conventions that return results as an
@@ -84,4 +86,13 @@ public enum EnumerableConvention implements Convention {
   RelTraitSet toTraits) {
 return true;
   }
+
+  public RelFactories.Struct getRelFactories() {
+return RelFactories.Struct.fromContext(
+Contexts.of(
+EnumerableRelFactories.ENUMERABLE_TABLE_SCAN_FACTORY,
+EnumerableRelFactories.ENUMERABLE_PROJECT_FACTORY,
+EnumerableRelFactories.ENUMERABLE_FILTER_FACTORY,
+EnumerableRelFactories.ENUMERABLE_SORT_FACTORY));
+  }
 }
diff --git 
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelFactories.java
 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelFactories.java
new file mode 100644
index 000..ab9cdd0
--- /dev/null
+++ 
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableRelFactories.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.adapter.enumerable;
+
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.CorrelationId;
+import org.apache.calcite.rel.hint.RelHint;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.rex.RexUtil;
+import org.apache.calcite.sql.validate.SqlValidatorUtil;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Contains factory interface and default implementation for creating various
+ * rel nodes.
+ */
+public class EnumerableRelFactories {
+
+  public static final org.apache.calcite.rel.core.RelFactories.TableScanFactory
+  ENUMERABLE_TABLE_SCAN_FACTORY = new TableScanFactor

[calcite] branch master updated (2b1254b -> b166b9a)

2020-05-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 2b1254b  [CALCITE-4009] Remove traitset remapping in 
ProjectJoinTransposeRule
 add b166b9a  [CALCITE-4004] Show RelOptRuleOperand description in debugger 
to facilitate debugging

No new revisions were added by this update.

Summary of changes:
 .../org/apache/calcite/plan/RelOptRuleOperand.java | 64 ++
 1 file changed, 64 insertions(+)



[calcite] branch master updated (2b1254b -> b166b9a)

2020-05-27 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 2b1254b  [CALCITE-4009] Remove traitset remapping in 
ProjectJoinTransposeRule
 add b166b9a  [CALCITE-4004] Show RelOptRuleOperand description in debugger 
to facilitate debugging

No new revisions were added by this update.

Summary of changes:
 .../org/apache/calcite/plan/RelOptRuleOperand.java | 64 ++
 1 file changed, 64 insertions(+)



[calcite] branch master updated: [CALCITE-4009] Remove traitset remapping in ProjectJoinTransposeRule

2020-05-26 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 2b1254b  [CALCITE-4009] Remove traitset remapping in 
ProjectJoinTransposeRule
2b1254b is described below

commit 2b1254bdec18f9e869f3287fb8ab471903e97829
Author: Haisheng Yuan 
AuthorDate: Sun May 24 14:47:51 2020 -0500

[CALCITE-4009] Remove traitset remapping in ProjectJoinTransposeRule

Remove traitset mapping that was added to ProjectJoinTransposeRule by
CALCITE-3353. Now it becomes obsolete, we should fail fast if that happens.
Otherwise, all the downstream projects that uses this rule will be wasted 
time
to deal with traitsets they don't need.
---
 .../rel/rules/ProjectJoinTransposeRule.java| 40 +-
 .../org/apache/calcite/test/RelOptRulesTest.java   | 49 --
 2 files changed, 2 insertions(+), 87 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
index 5d6510c..b0c1ef3 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
@@ -19,11 +19,6 @@ package org.apache.calcite.rel.rules;
 import org.apache.calcite.plan.RelOptRule;
 import org.apache.calcite.plan.RelOptRuleCall;
 import org.apache.calcite.plan.RelOptUtil;
-import org.apache.calcite.plan.RelTraitSet;
-import org.apache.calcite.rel.RelCollation;
-import org.apache.calcite.rel.RelCollationTraitDef;
-import org.apache.calcite.rel.RelCollations;
-import org.apache.calcite.rel.RelFieldCollation;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.core.Join;
 import org.apache.calcite.rel.core.Project;
@@ -35,9 +30,7 @@ import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexNode;
 import org.apache.calcite.rex.RexOver;
 import org.apache.calcite.rex.RexShuttle;
-import org.apache.calcite.rex.RexUtil;
 import org.apache.calcite.tools.RelBuilderFactory;
-import org.apache.calcite.util.mapping.Mappings;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -152,40 +145,11 @@ public class ProjectJoinTransposeRule extends RelOptRule 
implements Transformati
   projJoinFieldList,
   adjustments);
 }
-RelTraitSet traits = join.getTraitSet();
-final List originCollations = 
traits.getTraits(RelCollationTraitDef.INSTANCE);
-
-if (originCollations != null && !originCollations.isEmpty()) {
-  List newCollations = new ArrayList<>();
-  final int originLeftCnt = join.getLeft().getRowType().getFieldCount();
-  final Mappings.TargetMapping leftMapping = 
RelOptUtil.permutationPushDownProject(
-  ((Project) leftProjRel).getProjects(), 
join.getLeft().getRowType(),
-  0, 0);
-  final Mappings.TargetMapping rightMapping = 
RelOptUtil.permutationPushDownProject(
-  ((Project) rightProjRel).getProjects(), 
join.getRight().getRowType(),
-  originLeftCnt, leftProjRel.getRowType().getFieldCount());
-  for (RelCollation collation: originCollations) {
-List fc = new ArrayList<>();
-final List fieldCollations = 
collation.getFieldCollations();
-for (RelFieldCollation relFieldCollation: fieldCollations) {
-  final int fieldIndex = relFieldCollation.getFieldIndex();
-  Mappings.TargetMapping mapping = fieldIndex < originLeftCnt ? 
leftMapping : rightMapping;
-  RelFieldCollation newFieldCollation = RexUtil.apply(mapping, 
relFieldCollation);
-  if (newFieldCollation == null) {
-break;
-  }
-  fc.add(newFieldCollation);
-}
-newCollations.add(RelCollations.of(fc));
-  }
-  if (!newCollations.isEmpty()) {
-traits = traits.replace(newCollations);
-  }
-}
+
 // create a new join with the projected children
 Join newJoinRel =
 join.copy(
-traits,
+join.getTraitSet(),
 newJoinFilter,
 leftProjRel,
 rightProjRel,
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java 
b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index 9324d78..0c97896 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -132,7 +132,6 @@ import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.rex.RexInputRef;
 import org.apache.calcite.rex.RexNode;
-import org.apache.calcite.rex.RexOver;
 import org.apache.calcite.runtime.Hook;
 import org.apache.calcite.sql.SqlFunction;
 import org.apache.calcite.

[calcite] branch master updated: [CALCITE-3950] Doc of SqlGroupingFunction contradicts its behavior

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 b9a2075  [CALCITE-3950] Doc of SqlGroupingFunction contradicts its 
behavior
b9a2075 is described below

commit b9a2075ae125c318b6909b95d7ff0192fcec9149
Author: jinxing64 
AuthorDate: Thu Apr 23 21:10:16 2020 +0800

[CALCITE-3950] Doc of SqlGroupingFunction contradicts its behavior
---
 .../org/apache/calcite/sql/fun/SqlGroupingFunction.java  | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlGroupingFunction.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlGroupingFunction.java
index 522ba35..3fed6a6 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlGroupingFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlGroupingFunction.java
@@ -22,14 +22,16 @@ import org.apache.calcite.sql.type.OperandTypes;
 import org.apache.calcite.sql.type.ReturnTypes;
 
 /**
- * The {@code GROUPING} function.
+ * The {@code GROUPING} function. It accepts 1 or more arguments and they must 
be
+ * from the GROUP BY list. The result is calculated from a bitmap (the right 
most bit
+ * is the lowest), which indicates whether an argument is aggregated or grouped
+ * -- The N-th bit is lit if the N-th argument is aggregated.
  *
- * Accepts 1 or more arguments.
- * Example: {@code GROUPING(deptno, gender)} returns
- * 3 if both deptno and gender are being grouped,
- * 2 if only deptno is being grouped,
- * 1 if only gender is being groped,
- * 0 if neither deptno nor gender are being grouped.
+ * Example: {@code GROUPING(deptno, gender)} returns
+ * 0 if both deptno and gender are being grouped,
+ * 1 if only deptno is being grouped,
+ * 2 if only gender is being grouped,
+ * 3 if neither deptno nor gender are being grouped.
  *
  * This function is defined in the SQL standard.
  * {@code GROUPING_ID} is a non-standard synonym.



[calcite] branch master updated: [CALCITE-3999] Simplify DialectPool implementation using Guava cache

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 258f791  [CALCITE-3999] Simplify DialectPool implementation using 
Guava cache
258f791 is described below

commit 258f791eff12b4bac0fc11b4025aa5d99dcbbed1
Author: Jesus Camacho Rodriguez 
AuthorDate: Wed May 13 18:27:13 2020 -0700

[CALCITE-3999] Simplify DialectPool implementation using Guava cache
---
 .../org/apache/calcite/adapter/jdbc/JdbcUtils.java | 44 --
 1 file changed, 15 insertions(+), 29 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcUtils.java 
b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcUtils.java
index 0d207e1..b104b73 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcUtils.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcUtils.java
@@ -30,7 +30,6 @@ import org.apache.commons.dbcp2.BasicDataSource;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableList;
 import com.google.common.primitives.Ints;
 
 import java.sql.Connection;
@@ -41,10 +40,7 @@ import java.sql.SQLException;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.sql.Types;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.TimeZone;
 import javax.annotation.Nonnull;
 import javax.sql.DataSource;
@@ -59,37 +55,21 @@ final class JdbcUtils {
 
   /** Pool of dialects. */
   static class DialectPool {
-final Map> map0 = new 
IdentityHashMap<>();
-final Map map = new HashMap<>();
-
 public static final DialectPool INSTANCE = new DialectPool();
 
-// TODO: Discuss why we need a pool. If we do, I'd like to improve 
performance
-synchronized SqlDialect get(SqlDialectFactory dialectFactory, DataSource 
dataSource) {
-  Map dialectMap = map0.get(dataSource);
-  if (dialectMap != null) {
-final SqlDialect sqlDialect = dialectMap.get(dialectFactory);
-if (sqlDialect != null) {
-  return sqlDialect;
-}
-  }
+private final LoadingCache, 
SqlDialect> cache =
+CacheBuilder.newBuilder().softValues()
+.build(CacheLoader.from(DialectPool::dialect));
+
+private static @Nonnull SqlDialect dialect(
+@Nonnull Pair key) {
+  SqlDialectFactory dialectFactory = key.left;
+  DataSource dataSource = key.right;
   Connection connection = null;
   try {
 connection = dataSource.getConnection();
 DatabaseMetaData metaData = connection.getMetaData();
-String productName = metaData.getDatabaseProductName();
-String productVersion = metaData.getDatabaseProductVersion();
-List key = ImmutableList.of(productName, productVersion, 
dialectFactory);
-SqlDialect dialect = map.get(key);
-if (dialect == null) {
-  dialect = dialectFactory.create(metaData);
-  map.put(key, dialect);
-  if (dialectMap == null) {
-dialectMap = new IdentityHashMap<>();
-map0.put(dataSource, dialectMap);
-  }
-  dialectMap.put(dialectFactory, dialect);
-}
+SqlDialect dialect = dialectFactory.create(metaData);
 connection.close();
 connection = null;
 return dialect;
@@ -105,6 +85,12 @@ final class JdbcUtils {
 }
   }
 }
+
+public SqlDialect get(SqlDialectFactory dialectFactory, DataSource 
dataSource) {
+  final Pair key =
+  Pair.of(dialectFactory, dataSource);
+  return cache.getUnchecked(key);
+}
   }
 
   /** Builder that calls {@link ResultSet#getObject(int)} for every column,



[calcite] branch master updated: [CALCITE-3910] Enhance ProjectJoinTransposeRule to support SemiJoin and AntiJoin (Liya Fan)

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 39cb3e3  [CALCITE-3910] Enhance ProjectJoinTransposeRule to support 
SemiJoin and AntiJoin (Liya Fan)
39cb3e3 is described below

commit 39cb3e3619a528bb39a677598f16a26f10afbfaf
Author: liyafan82 
AuthorDate: Wed Apr 15 15:38:38 2020 +0800

[CALCITE-3910] Enhance ProjectJoinTransposeRule to support SemiJoin and 
AntiJoin (Liya Fan)

Close #1917
---
 .../rel/rules/ProjectJoinTransposeRule.java|  4 --
 .../apache/calcite/rel/rules/PushProjector.java| 33 ++---
 .../org/apache/calcite/test/RelOptRulesTest.java   | 78 ++
 .../org/apache/calcite/test/RelOptRulesTest.xml| 58 
 4 files changed, 158 insertions(+), 15 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
index b975a3b..5d6510c 100644
--- 
a/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
+++ 
b/core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java
@@ -93,10 +93,6 @@ public class ProjectJoinTransposeRule extends RelOptRule 
implements Transformati
 Project origProj = call.rel(0);
 final Join join = call.rel(1);
 
-if (!join.getJoinType().projectsRight()) {
-  return; // TODO: support SemiJoin / AntiJoin
-}
-
 // Normalize the join condition so we don't end up misidentified expanded
 // form of IS NOT DISTINCT FROM as PushProject also visit the filter 
condition
 // and push down expressions.
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/PushProjector.java 
b/core/src/main/java/org/apache/calcite/rel/rules/PushProjector.java
index 7ec5482..fcbd60e 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/PushProjector.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/PushProjector.java
@@ -25,6 +25,7 @@ import org.apache.calcite.rel.core.Join;
 import org.apache.calcite.rel.core.JoinRelType;
 import org.apache.calcite.rel.core.Project;
 import org.apache.calcite.rel.core.SetOp;
+import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.rex.RexBuilder;
 import org.apache.calcite.rex.RexCall;
@@ -40,6 +41,7 @@ import org.apache.calcite.util.Pair;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
 import java.util.BitSet;
@@ -47,6 +49,8 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Set;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 /**
  * PushProjector is a utility class used to perform operations used in push
@@ -216,9 +220,14 @@ public class PushProjector {
   origProjExprs = origProj.getProjects();
 }
 
-childFields = childRel.getRowType().getFieldList();
+if (childRel instanceof Join) {
+  Join join = (Join) childRel;
+  childFields = 
Lists.newArrayList(join.getLeft().getRowType().getFieldList());
+  childFields.addAll(join.getRight().getRowType().getFieldList());
+} else {
+  childFields = childRel.getRowType().getFieldList();
+}
 nChildFields = childFields.size();
-
 projRefs = new BitSet(nChildFields);
 if (childRel instanceof Join) {
   Join joinRel = (Join) childRel;
@@ -227,14 +236,7 @@ public class PushProjector {
   List rightFields =
   joinRel.getRight().getRowType().getFieldList();
   nFields = leftFields.size();
-  switch (joinRel.getJoinType()) {
-  case SEMI:
-  case ANTI:
-nFieldsRight = 0;
-break;
-  default:
-nFieldsRight = rightFields.size();
-  }
+  nFieldsRight = rightFields.size();
   nSysFields = joinRel.getSystemFieldList().size();
   childBitmap =
   ImmutableBitSet.range(nSysFields, nFields + nSysFields);
@@ -469,7 +471,8 @@ public class PushProjector {
 // referenced and there are no special preserve expressions; note
 // that we need to do this check after we've handled the 0-column
 // project cases
-if (projRefs.cardinality() == nChildFields
+boolean allFieldsReferenced = IntStream.range(0, nChildFields).allMatch(i 
-> projRefs.get(i));
+if (allFieldsReferenced
 && childPreserveExprs.size() == 0
 && rightPreserveExprs.size() == 0) {
   return true;
@@ -547,6 +550,14 @@ public class PushProjector {
   } else {
 newExpr = projExpr;
   }
+
+  List typeList = projChild.getRowType().getFieldList()
+  .stream().map(field -> field.getType()).col

[calcite] branch master updated: [CALCITE-3988] Intersect in RelMdRowCount doesn't take into account 'intersect all' (Xu Zhaohui)

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7952cd5  [CALCITE-3988] Intersect in RelMdRowCount doesn't take into 
account 'intersect all' (Xu Zhaohui)
7952cd5 is described below

commit 7952cd550a7fac127a6cd7db44fd70c9d1e16d50
Author: xzh <953396...@qq.com>
AuthorDate: Mon May 11 14:28:06 2020 +0800

[CALCITE-3988] Intersect in RelMdRowCount doesn't take into account 
'intersect all' (Xu Zhaohui)

Close #1972
---
 .../main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java| 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java 
b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
index ec7f497..a42ed2a 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
@@ -108,7 +108,11 @@ public class RelMdRowCount
 rowCount = partialRowCount;
   }
 }
-return rowCount;
+if (rowCount == null || !rel.all) {
+  return rowCount;
+} else {
+  return rowCount * 2;
+}
   }
 
   public Double getRowCount(Minus rel, RelMetadataQuery mq) {



[calcite] branch master updated: [CALCITE-3985] Simplify grouped window function in parser (Rui Wang)

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 2ba5519  [CALCITE-3985] Simplify grouped window function in parser 
(Rui Wang)
2ba5519 is described below

commit 2ba551905c4ae99be2c68e0c75301d9287d7b61a
Author: amaliujia 
AuthorDate: Wed May 13 10:38:49 2020 -0700

[CALCITE-3985] Simplify grouped window function in parser (Rui Wang)

"s = span()" can be promoted such that TUMBLE/HOP/SESSION can share the
same code.

Close #1974
---
 core/src/main/codegen/templates/Parser.jj | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/src/main/codegen/templates/Parser.jj 
b/core/src/main/codegen/templates/Parser.jj
index 18c3242..835fd4a 100644
--- a/core/src/main/codegen/templates/Parser.jj
+++ b/core/src/main/codegen/templates/Parser.jj
@@ -6056,22 +6056,22 @@ SqlCall GroupByWindowingCall():
 (
 
 {
-s = span();
 op = SqlStdOperatorTable.TUMBLE_OLD;
 }
 |
 
 {
-s = span();
 op = SqlStdOperatorTable.HOP_OLD;
 }
 |
 
 {
-s = span();
 op = SqlStdOperatorTable.SESSION_OLD;
 }
 )
+{
+s = span();
+}
 args = UnquantifiedFunctionParameterList(ExprContext.ACCEPT_SUB_QUERY) {
 return op.createCall(s.end(this), args);
 }



[calcite] branch master updated: Doc: Update site README.md

2020-05-24 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 4a2e923  Doc: Update site README.md
4a2e923 is described below

commit 4a2e923ae025ac182c6c0c3b05b7650c057de92c
Author: Haisheng Yuan 
AuthorDate: Sun May 24 02:08:59 2020 -0500

Doc: Update site README.md
---
 site/README.md | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/site/README.md b/site/README.md
index 8cbac2b..90c5fa2 100644
--- a/site/README.md
+++ b/site/README.md
@@ -46,7 +46,7 @@ Site generation currently works best with ruby-2.5.1.
`rmdir site\target\javadocAggregate /S /Q` (Windows)
 4. `mkdir site/target`
`mkdir site\target` (Windows)
-4. `mv build/docs/javadocAggregate site/target`
+5. `mv build/docs/javadocAggregate site/target`
`for /d %a in (build\docs\javadocAggregate*) do move %a site\target` 
(Windows)
 
 ### Running locally
@@ -89,8 +89,9 @@ As you make changes to the site, the site will automatically 
rebuild.
 
 1. `cd site/target`
 2. `git init`
-3. `git remote add origin https://github.com/apache/calcite-site`
-4. `git reset origin/master --soft`
+3. `git remote add origin g...@github.com:apache/calcite-site.git`
+4. `git fetch`
+5. `git reset origin/master --soft`
 
 If you have not regenerated the javadoc and they are missing, restore them:
 



[calcite] branch site updated (d2e2d7c -> b708fdc)

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch site
in repository https://gitbox.apache.org/repos/asf/calcite.git.


 discard d2e2d7c  Site: Change affiliation of Stamatis Zampetakis
 discard 3a1e312  Site: Add Forward Xu, Jin Xing, Wang Yanlin, as committers
 discard bcfb500  Site: Add Vineet Garg as committer
 discard f7d7079  Site: Add Feng Zhu as committer
 add 0f7dcfb  [CALCITE-3819] Prune parent RelNode when merging child RelSet 
with parent RelSet
 add 74536b7  [CALCITE-3838] Support Calc in 
RelMdSize,RelMdSelectivity,RelMdMaxRowCount,RelMdMinRowCount,RelMdTableReferences
 add b632152  [CALCITE-3839] After calling RelBuilder.aggregate, cannot 
lookup field by name
 add 91f5bb5  [CALCITE-3412] FLOOR(timestamp TO WEEK) gives wrong result
 add 4208d0b  [CALCITE-3823] Do not use String.replaceAll
 add 80e6b02  [CALCITE-3753] Remove rule queue importance
 add 15fa9bc  [CALCITE-3753] Introduce SubstitutionRule interface and 
execute substitutional rule first
 add 8d4820f  [CALCITE-3847] Decorrelation for join with lateral table 
outputs wrong plan if the join condition contains correlation variables
 add ad8cf7e  [CALCITE-3845] CASE WHEN expression with nullability CAST is 
considered as reduced wrongly in ReduceExpressionsRule
 add 18b9bc3  [CALCITE-3848] Rewriting for materialized view consisting of 
group by on join keys fails with Mappings$NoElementException (Vineet Garg)
 add bc2d7e1  [CALCITE-3853] Minor improvements in SortJoinCopyRule
 add b523007  [CALCITE-3855] Supports snapshot on table with virtual 
columns during sql-to-rel conversion
 add 4c3cef9  [CALCITE-3856] Remove code to be removed before 1.23
 add 1eff60b  [CALCITE-3704] Implement STRCMP function
 add f5a  [CALCITE-3815] Add missing SQL standard aggregate functions: 
EVERY, SOME, INTERSECTION
 add 6dfcfb4  [CALCITE-3726] Allow declaring type objects (ritesh-kapoor)
 add 468f019  [CALCITE-3647] MySQL COMPRESS function support (ritesh-kapoor)
 add d234626  [CALCITE-3694] Implement SINH function
 add 0e345fd  [CALCITE-3862] Materialized view rewriting algorithm throws 
IndexOutOfBoundsException (Vineet Garg)
 add 2f507f1  [CALCITE-3634] Add IntersectOnCalcsToIntersectUnifyRule for 
materialized view recognition (dz)
 add a8aa439  [CALCITE-3852] RexSimplify doesn't simplify NOT EQUAL 
predicates
 add f76ddd1  [CALCITE-3285] EnumerableMergeJoin should support non-equi 
join conditions
 add 79d5001  [CALCITE-3810] Render ANTI and SEMI join to NOT EXISTS and 
EXISTS in the JDBC adapter. Also add forgotten IS_DISTINCT_FROM translation 
support
 add 893d41f  [CALCITE-3840] Re-aliasing of VALUES that has column aliases 
produces wrong SQL in the JDBC adapter
 add ee9f35c  Bump release-plugins: 1.61 -> 1.65
 add 4a644e5  [CALCITE-3660] Disable 
PigRelBuilderStyleTest#testImplWithJoin since it fails too often for no reason
 add ffcfb92  [CALCITE-3829] MergeJoinEnumerator should not use inputs 
enumerators until it is really required
 add c60f675  Update Gradle: 6.1.1 -> 6.3
 add 989fc12  [CALCITE-3660] Disable 
PigRelBuilderStyleTest#testScanAndFilter since it fails too often for no reason
 add ebbba56  [CALCITE-3871] Remove dependency of 
org.apiguardian:apiguardian-api
 add 8a80b72  [CALCITE-3846] EnumerableMergeJoin: wrong comparison of 
composite key with null values
 add 888dd3a  [CALCITE-3684] Supports CONCAT for variable arguments (Wenhui 
Tang)
 add 1c261eb  [CALCITE-3882] Remove duplicated code from 
SqlTypeAssignmentRule (Wenhui Tang)
 add 6218661  [CALCITE-3867] Support RelDistribution json serialization 
(Krisztian Kasa)
 add 08f4a98  [CALCITE-3886] Execute substitution rule according to the 
order they get matched
 add 7d4c969  Following [CALCITE-3819] Prune parent RelNode when merging 
child RelSet with parent RelSet
 add 56c4c42  [CALCITE-3885] Restore trace logging for rules queue and 
Volcano planner's internal state (Roman Kondakov)
 add a0ef3c9  [CALCITE-3660] Disable flaky test PigRelBuilderStyleTest
 add 4a8e105  [CALCITE-3888] Switch avatica-server to be test dependency 
for core
 add 0be2961  Site: Fix links to javadoc
 add b4ad630  Simplify buildSqllineClasspath build tasks
 add 8849b62  [CALCITE-3880] Add SortExchange support to RelFieldTrimmer 
(Krisztian Kasa)
 add 7792d57  [CALCITE-3891] Remove use of Pair.zip in RelTraitSet
 add b9a0fac  Update release-plugins: 1.65 -> 1.70
 add d0180d1  Add icon for JetBrains Toolbox
 add df3e3c6  [CALCITE-3876] RelToSqlConverter should not merge a Project 
that contains a window function that references a window function in input 
Project
 add ddda872  [CALCITE-3877] In RexWindow, make fields upperBound and 
lowerBound not-nullable
 add f1b2d3c  [CALCITE-3814] Support JDK 14 and guava 28.2-jre
 add 9492dd4  [CALCITE-3

[calcite] branch master updated (b708fdc -> dfea387)

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from b708fdc  [CALCITE-3989] Release Calcite 1.23.0
 add 090154a  Improve 1.23.0 release note and document
 add 4346321  Prepare for next development iteration
 add dfea387  Add 1.23.0 release announcement

No new revisions were added by this update.

Summary of changes:
 gradle.properties|   2 +-
 site/_docs/history.md| 420 +--
 site/_docs/howto.md  |   8 +-
 site/_posts/2020-05-23-release-1.23.0.md |  49 
 4 files changed, 343 insertions(+), 136 deletions(-)
 create mode 100644 site/_posts/2020-05-23-release-1.23.0.md



[calcite] 03/03: Add 1.23.0 release announcement

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit dfea3871b863436d8c93f92377a5fb92520cd8c7
Author: Haisheng Yuan 
AuthorDate: Sat May 23 22:23:51 2020 -0500

Add 1.23.0 release announcement
---
 site/_posts/2020-05-23-release-1.23.0.md | 49 
 1 file changed, 49 insertions(+)

diff --git a/site/_posts/2020-05-23-release-1.23.0.md 
b/site/_posts/2020-05-23-release-1.23.0.md
new file mode 100644
index 000..60ef7c5
--- /dev/null
+++ b/site/_posts/2020-05-23-release-1.23.0.md
@@ -0,0 +1,49 @@
+---
+layout: news_item
+date: "2020-05-23 22:30:00 -0500"
+author: hyuan
+version: 1.23.0
+categories: [release]
+tag: v1-23-0
+sha: b708fdc46d4c5fd4c5a6c7a398823318a7b4dce3
+---
+
+
+The [Apache Calcite PMC]({{ site.baseurl }})
+is pleased to announce
+[Apache Calcite release 1.23.0]({{ site.baseurl }}/docs/history.html#v1-23-0).
+
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as performance improvements
+and bug-fixes. For some complex queries, the planning speed can be 50x or more
+faster than previous versions with built-in default rule set. It is also worth
+highlighting that Calcite now:
+
+* Supports top down trait request and trait enforcement without abstract 
converter
+  (https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896)
+* Improves `VolcanoPlanner` performance by removing rule match and subset 
importance
+  (https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753)
+* Improves `VolcanoPlanner` performance when abstract converter is enabled
+  (https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970)
+* Supports ClickHouse dialect
+  (https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157)
+* Supports `SESSION` and `HOP` Table function
+  (https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780,
+  https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737)



[calcite] 01/03: Improve 1.23.0 release note and document

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 090154a9efc482ca6a597abe1558cb3f8c48d576
Author: Haisheng Yuan 
AuthorDate: Sat May 23 13:10:59 2020 -0500

Improve 1.23.0 release note and document
---
 site/_docs/history.md | 420 ++
 site/_docs/howto.md   |   8 +-
 2 files changed, 293 insertions(+), 135 deletions(-)

diff --git a/site/_docs/history.md b/site/_docs/history.md
index 5d0c491..7e40ae4 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,22 +28,27 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-15
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-23
 {: #v1-23-0}
 
 This release comes two months after 1.22.0. It includes more than 100 resolved
 issues, comprising a lot of new features as well as performance improvements
-and bug-fixes. This is the fastest version of Calcite, for some complex 
queries,
-the planning speed can be 50x or more faster than previous versions with 
built-in
-default rule set. TPC-H queries that can't finish planning in previous versions
-now can finish in several seconds. Among others, it is worth highlighting the 
following.
-
-* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
-* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
-* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
-* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
-* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
-* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+and bug-fixes. For some complex queries, the planning speed can be 50x or more
+faster than previous versions with built-in default rule set. It is also worth
+highlighting the following.
+
+* `VolcanoPlanner` supports top down trait request and trait enforcement 
without
+  abstract converter
+  (https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896)
+* Improve `VolcanoPlanner` performance by removing rule match and subset 
importance
+  (https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753)
+* Improve `VolcanoPlanner` performance when abstract converter is enabled
+  (https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970)
+* Support ClickHouse dialect
+  (https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157)
+* Support `SESSION` and `HOP` Table function
+  (https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780,
+  https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737)
 
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
@@ -52,132 +57,282 @@ gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
-* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
-* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
-* [https://issues.apache.org/jira/browse/CALCITE-3997;>CALCITE-3997] In 
`VolcanoPlanner`, transformation rules won't match with Enumerable physical 
operators
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
+  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868]
+  Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753]
+  `VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively
+  use `checkCancel()` to achieve `impatient` mode
+* [https://issues.apache.org/jira/browse/CALCITE-3997;>CALCITE-3997]
+  In `VolcanoPlanner`, transformation rules won't match with Enumerable 
physical
+  operators
+* [https://issues.apache.org/jira/browse/CALCITE-3825;>CALCITE-3825]
+  Split `AbstractMaterializedViewRule` into multiple classes (adden

[calcite] 02/03: Prepare for next development iteration

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 4346321972b94ff1582368afe40d0241fb9f20bd
Author: Haisheng Yuan 
AuthorDate: Sat May 23 22:00:40 2020 -0500

Prepare for next development iteration
---
 gradle.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gradle.properties b/gradle.properties
index e460e24..ea5b9aa 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -23,7 +23,7 @@ kotlin.parallel.tasks.in.project=true
 # This is version for Calcite itself
 # Note: it should not include "-SNAPSHOT" as it is automatically added by 
build.gradle.kts
 # Release version can be generated by using -Prelease or -Prc= arguments
-calcite.version=1.23.0
+calcite.version=1.24.0
 # This is a version to be used from Maven repository. It can be overridden by 
localAvatica below
 calcite.avatica.version=1.16.0
 



[calcite] branch branch-1.23 updated (b708fdc -> dfea387)

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from b708fdc  [CALCITE-3989] Release Calcite 1.23.0
 new 090154a  Improve 1.23.0 release note and document
 new 4346321  Prepare for next development iteration
 new dfea387  Add 1.23.0 release announcement

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gradle.properties|   2 +-
 site/_docs/history.md| 420 +--
 site/_docs/howto.md  |   8 +-
 site/_posts/2020-05-23-release-1.23.0.md |  49 
 4 files changed, 343 insertions(+), 136 deletions(-)
 create mode 100644 site/_posts/2020-05-23-release-1.23.0.md



svn commit: r39742 - /release/calcite/apache-calcite-1.21.0/

2020-05-23 Thread hyuan
Author: hyuan
Date: Sat May 23 16:13:29 2020
New Revision: 39742

Log:
Remove apache-calcite-1.21.0

Removed:
release/calcite/apache-calcite-1.21.0/



[calcite] annotated tag calcite-1.23.0 updated (b708fdc -> 7c3001d)

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to annotated tag calcite-1.23.0
in repository https://gitbox.apache.org/repos/asf/calcite.git.


*** WARNING: tag calcite-1.23.0 was modified! ***

from b708fdc  (commit)
  to 7c3001d  (tag)
 tagging b708fdc46d4c5fd4c5a6c7a398823318a7b4dce3 (commit)
 replaces calcite-1.21.0
  by Haisheng Yuan
  on Sat May 23 10:31:17 2020 -0500

- Log -
---


No new revisions were added by this update.

Summary of changes:



svn commit: r39741 - /dev/calcite/apache-calcite-1.23.0-rc1/ /release/calcite/apache-calcite-1.23.0/

2020-05-23 Thread hyuan
Author: hyuan
Date: Sat May 23 15:26:28 2020
New Revision: 39741

Log:
Promoting Apache Calcite calcite-1.23.0-rc1 -> calcite-1.23.0 to release area

Added:
release/calcite/apache-calcite-1.23.0/
release/calcite/apache-calcite-1.23.0/apache-calcite-1.23.0-src.tar.gz
  - copied unchanged from r39622, 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz
release/calcite/apache-calcite-1.23.0/apache-calcite-1.23.0-src.tar.gz.asc
  - copied unchanged from r39622, 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.asc

release/calcite/apache-calcite-1.23.0/apache-calcite-1.23.0-src.tar.gz.sha512
  - copied unchanged from r39622, 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.sha512
Removed:
dev/calcite/apache-calcite-1.23.0-rc1/



[calcite] branch master updated (05376d6 -> b708fdc)

2020-05-23 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 05376d6  Following [CALCITE-3997] Remove TransformationRule from 
CalcMergeRule temporarily
 add b708fdc  [CALCITE-3989] Release Calcite 1.23.0

No new revisions were added by this update.

Summary of changes:
 README|   2 +-
 site/_docs/history.md | 162 --
 site/_docs/howto.md   |   6 +-
 3 files changed, 161 insertions(+), 9 deletions(-)



[calcite] annotated tag calcite-1.23.0-rc1 updated (b708fdc -> dc88515)

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to annotated tag calcite-1.23.0-rc1
in repository https://gitbox.apache.org/repos/asf/calcite.git.


*** WARNING: tag calcite-1.23.0-rc1 was modified! ***

from b708fdc  (commit)
  to dc88515  (tag)
 tagging b708fdc46d4c5fd4c5a6c7a398823318a7b4dce3 (commit)
 replaces calcite-1.21.0
  by Haisheng Yuan
  on Fri May 15 22:56:05 2020 -0500

- Log -
---


No new revisions were added by this update.

Summary of changes:



svn commit: r39622 - in /dev/calcite/apache-calcite-1.23.0-rc1: ./ apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-15 Thread hyuan
Author: hyuan
Date: Sat May 16 03:54:03 2020
New Revision: 39622

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc1 to dev area

Added:
dev/calcite/apache-calcite-1.23.0-rc1/
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.sha512

Added: dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz
==
Binary files 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz (added) 
and dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz Sat 
May 16 03:54:03 2020 differ

Added: 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.asc
==
--- dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.asc 
(added)
+++ dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.asc 
Sat May 16 03:54:03 2020
@@ -0,0 +1,17 @@
+-BEGIN PGP SIGNATURE-
+Version: BCPG v1.64
+
+iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl6/Y4sACgkQPNIqusUN
+3O/K9hAAiISvbjNJdyWczIWwV7u7QjHp7EQGmPVrNqlB6AkjBBJeHVLZTjaltZSs
+YpYfem+qfIaSz4mdUcLrqWtkX+a2edZqonEEveb7y8YlkD/Q7+ovUSEBNtHx67Wn
+6ZA6i11w0XeyKzSfMUrp3jl7veRYvybmKsdXIdqXzK7nhxsCyjdQaCDvOdYUvQrF
+GzE3NThgHfcxwfIcme9pVYwHWVMCR8YDWDvJoqGKgCe+32DFdVy6v2KLoPUMvmSI
+JDoWumAqdLKrEZ+5ERVAxPWlTaErNvUiBATS4a5iQ0QKX3MO//Z3aDAonEBmOkJh
+AOBqvoFt55r1YcwraOhAEcJEylzxlgWBAwFP4gDE3rWkAaGt0ggr707c05IhxU8w
+birSW0L1xzWJ0Aa8DpBW9R8lim1L/Rq1SViZfmx5f+GaKlLPPnpL5vIKJwKPFVtY
+AupFmFy/ovlhkMHkxM4O//HBEREAXIc3MdOCLjbIjMijkTULq8I7InePOI3l0Ndo
+aF6DDBbCHU3nAcomSOzFSGC5VvVwvCTagdjJ2cr6yPlOeFh/7M30a8RrQ1uQh7LK
+d0EXw953dt3URoqcf5glDqu+FqA+0Rv4xUmj0zwWXn/9NxmsVbErHagBGooNFj0o
+2mWvrp3kZDN3+6kdPapev24/hr9Bag1i+hU2NirVR1N6TuzNmgc=
+=QOT1
+-END PGP SIGNATURE-

Added: 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.sha512
==
--- 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.sha512 
(added)
+++ 
dev/calcite/apache-calcite-1.23.0-rc1/apache-calcite-1.23.0-src.tar.gz.sha512 
Sat May 16 03:54:03 2020
@@ -0,0 +1 @@
+961c4f13199e199c669a6168ba655a9492bdd80d644da375a684b732c0b628b8a2ffacea5da97c82e8702a8e3bf7a1f58784baa49509fb3c48ef593259e11f46
 *apache-calcite-1.23.0-src.tar.gz




[calcite] 01/01: [CALCITE-3989] Release Calcite 1.23.0

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit b708fdc46d4c5fd4c5a6c7a398823318a7b4dce3
Author: Haisheng Yuan 
AuthorDate: Mon May 11 18:48:12 2020 -0500

[CALCITE-3989] Release Calcite 1.23.0
---
 README|   2 +-
 site/_docs/history.md | 162 --
 site/_docs/howto.md   |   6 +-
 3 files changed, 161 insertions(+), 9 deletions(-)

diff --git a/README b/README
index 7eeca3a..b03b439 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Calcite release 1.22.0
+Apache Calcite release 1.23.0
 
 This is a source or binary distribution of Apache Calcite.
 
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 04dc02f..5d0c491 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,18 +28,170 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ under development
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-15
 {: #v1-23-0}
 
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as performance improvements
+and bug-fixes. This is the fastest version of Calcite, for some complex 
queries,
+the planning speed can be 50x or more faster than previous versions with 
built-in
+default rule set. TPC-H queries that can't finish planning in previous versions
+now can finish in several seconds. Among others, it is worth highlighting the 
following.
+
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
+* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
-Guava versions 19.0 to 28.2-jre; Apache Flink 1.10.0;
-other software versions as specified in gradle.properties.
+Guava versions 19.0 to 28.2-jre; other software versions as specified in
+gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
-  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
+* [https://issues.apache.org/jira/browse/CALCITE-3997;>CALCITE-3997] In 
`VolcanoPlanner`, transformation rules won't match with Enumerable physical 
operators
+
+ New features
+
+* [https://issues.apache.org/jira/browse/CALCITE-3984;>CALCITE-3984] 
Support `Exchange` operator in `RelFieldTrimmer` (Xu Zhaohui)
+* [https://issues.apache.org/jira/browse/CALCITE-3971;>CALCITE-3971] 
Support `Calc` in `RelMdColumnOrigins` (Xu ZhaoHui)
+* [https://issues.apache.org/jira/browse/CALCITE-3921;>CALCITE-3921] 
Support `TableModify` json serialization and deserialization (Wang Yanlin)
+* [https://issues.apache.org/jira/browse/CALCITE-3938;>CALCITE-3938] 
Support `LogicalCalc` in `RelShuttle` (dz)
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3880;>CALCITE-3880] Add 
`SortExchange` support to `RelFieldTrimmer` (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3867;>CALCITE-3867] 
Support `RelDistribution` json serialization (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table fun

[calcite] branch branch-1.23 updated (2143ac6 -> b708fdc)

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


 discard 2143ac6  [CALCITE-3989] Release Calcite 1.23.0
 new b708fdc  [CALCITE-3989] Release Calcite 1.23.0

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (2143ac6)
\
 N -- N -- N   refs/heads/branch-1.23 (b708fdc)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 site/_docs/history.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



[calcite] 01/01: [CALCITE-3989] Release Calcite 1.23.0

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 2143ac6510d9cc8b34a75c17b7b69af3d8f437e0
Author: Haisheng Yuan 
AuthorDate: Mon May 11 18:48:12 2020 -0500

[CALCITE-3989] Release Calcite 1.23.0
---
 README|   2 +-
 site/_docs/history.md | 162 --
 site/_docs/howto.md   |   6 +-
 3 files changed, 161 insertions(+), 9 deletions(-)

diff --git a/README b/README
index 7eeca3a..b03b439 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Calcite release 1.22.0
+Apache Calcite release 1.23.0
 
 This is a source or binary distribution of Apache Calcite.
 
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 04dc02f..15f5202 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,18 +28,170 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ under development
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-15
 {: #v1-23-0}
 
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as performance improvements
+and bug-fixes. This is the fastest version of Calcite, for some complex 
queries,
+the planning speed can be 50x or more faster than previous versions. TPC-H
+queries that can't finish planning in previous versions now can finish in
+several seconds. Among others, it is worth highlighting the following.
+
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
+* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
-Guava versions 19.0 to 28.2-jre; Apache Flink 1.10.0;
-other software versions as specified in gradle.properties.
+Guava versions 19.0 to 28.2-jre; other software versions as specified in
+gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
-  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
+* [https://issues.apache.org/jira/browse/CALCITE-3997;>CALCITE-3997] In 
`VolcanoPlanner`, transformation rules won't match with Enumerable physical 
operators
+
+ New features
+
+* [https://issues.apache.org/jira/browse/CALCITE-3984;>CALCITE-3984] 
Support `Exchange` operator in `RelFieldTrimmer` (Xu Zhaohui)
+* [https://issues.apache.org/jira/browse/CALCITE-3971;>CALCITE-3971] 
Support `Calc` in `RelMdColumnOrigins` (Xu ZhaoHui)
+* [https://issues.apache.org/jira/browse/CALCITE-3921;>CALCITE-3921] 
Support `TableModify` json serialization and deserialization (Wang Yanlin)
+* [https://issues.apache.org/jira/browse/CALCITE-3938;>CALCITE-3938] 
Support `LogicalCalc` in `RelShuttle` (dz)
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3880;>CALCITE-3880] Add 
`SortExchange` support to `RelFieldTrimmer` (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3867;>CALCITE-3867] 
Support `RelDistribution` json serialization (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://

[calcite] branch branch-1.23 updated (edc37c0 -> 2143ac6)

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


omit edc37c0  [CALCITE-3989] Release Calcite 1.23.0
 add ffa22f7  [CALCITE-3979] Simplification might have removed CAST 
expression(s) incorrectly
 add 7be30db  [CALCITE-3997] Logical rules matched with physical operators 
but failed to handle traits
 add 05376d6  Following [CALCITE-3997] Remove TransformationRule from 
CalcMergeRule temporarily
 new 2143ac6  [CALCITE-3989] Release Calcite 1.23.0

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (edc37c0)
\
 N -- N -- N   refs/heads/branch-1.23 (2143ac6)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/calcite/plan/volcano/RuleQueue.java |  2 +-
 .../calcite/plan/volcano/VolcanoPlanner.java   | 10 +++
 .../calcite/plan/volcano/VolcanoRuleCall.java  |  2 +-
 .../rel/rules/AbstractJoinExtractFilterRule.java   |  3 +-
 .../rel/rules/AggregateCaseToFilterRule.java   |  3 +-
 .../AggregateExpandDistinctAggregatesRule.java |  3 +-
 .../rel/rules/AggregateExtractProjectRule.java |  3 +-
 .../rel/rules/AggregateFilterTransposeRule.java|  3 +-
 .../rel/rules/AggregateJoinJoinRemoveRule.java |  3 +-
 .../calcite/rel/rules/AggregateJoinRemoveRule.java |  2 +-
 .../rel/rules/AggregateJoinTransposeRule.java  |  2 +-
 .../calcite/rel/rules/AggregateMergeRule.java  |  2 +-
 .../rel/rules/AggregateProjectMergeRule.java   |  2 +-
 .../rules/AggregateProjectPullUpConstantsRule.java |  3 +-
 .../rel/rules/AggregateReduceFunctionsRule.java|  3 +-
 .../calcite/rel/rules/AggregateRemoveRule.java |  3 +-
 .../calcite/rel/rules/AggregateStarTableRule.java  |  2 +-
 .../rel/rules/AggregateUnionAggregateRule.java |  2 +-
 .../rel/rules/AggregateUnionTransposeRule.java |  2 +-
 .../calcite/rel/rules/AggregateValuesRule.java |  1 -
 .../apache/calcite/rel/rules/CalcRemoveRule.java   |  1 -
 .../apache/calcite/rel/rules/CalcSplitRule.java|  2 +-
 .../apache/calcite/rel/rules/CoerceInputsRule.java |  2 +-
 .../apache/calcite/rel/rules/DateRangeRules.java   |  2 +-
 .../rel/rules/ExchangeRemoveConstantKeysRule.java  |  1 -
 .../rel/rules/FilterAggregateTransposeRule.java|  2 +-
 .../calcite/rel/rules/FilterCalcMergeRule.java |  2 +-
 .../calcite/rel/rules/FilterCorrelateRule.java |  2 +-
 .../apache/calcite/rel/rules/FilterJoinRule.java   |  2 +-
 .../apache/calcite/rel/rules/FilterMergeRule.java  |  1 -
 .../rel/rules/FilterMultiJoinMergeRule.java|  2 +-
 .../rel/rules/FilterProjectTransposeRule.java  |  2 +-
 .../rules/FilterRemoveIsNotDistinctFromRule.java   |  3 +-
 .../rel/rules/FilterSetOpTransposeRule.java|  2 +-
 .../rules/FilterTableFunctionTransposeRule.java|  3 +-
 .../apache/calcite/rel/rules/FilterToCalcRule.java |  2 +-
 .../calcite/rel/rules/IntersectToDistinctRule.java |  2 +-
 .../rel/rules/JoinAddRedundantSemiJoinRule.java|  3 +-
 .../calcite/rel/rules/JoinAssociateRule.java   |  2 +-
 .../apache/calcite/rel/rules/JoinCommuteRule.java  |  2 +-
 .../rel/rules/JoinProjectTransposeRule.java|  2 +-
 .../calcite/rel/rules/JoinPushExpressionsRule.java |  2 +-
 .../calcite/rel/rules/JoinPushThroughJoinRule.java |  2 +-
 .../rules/JoinPushTransitivePredicatesRule.java|  2 +-
 .../calcite/rel/rules/JoinToCorrelateRule.java |  2 +-
 .../calcite/rel/rules/JoinToMultiJoinRule.java |  2 +-
 .../calcite/rel/rules/JoinUnionTransposeRule.java  |  2 +-
 .../calcite/rel/rules/LoptOptimizeJoinRule.java|  2 +-
 .../org/apache/calcite/rel/rules/MatchRule.java|  2 +-
 .../rel/rules/MaterializedViewFilterScanRule.java  |  2 +-
 .../rel/rules/MultiJoinOptimizeBushyRule.java  |  2 +-
 .../calcite/rel/rules/ProjectCalcMergeRule.java|  2 +-
 .../rel/rules/ProjectCorrelateTransposeRule.java   |  2 +-
 .../rel/rules/ProjectFilterTransposeRule.java  |  2 +-
 .../rel/rules/ProjectJoinJoinRemoveRule.java   |  1 -
 .../calcite/rel/rules/ProjectJoinRemoveRule.java   |  1 -
 .../rel/rules/ProjectJoinTransposeRule.java 

[calcite] branch master updated: Following [CALCITE-3997] Remove TransformationRule from CalcMergeRule temporarily

2020-05-15 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 05376d6  Following [CALCITE-3997] Remove TransformationRule from 
CalcMergeRule temporarily
05376d6 is described below

commit 05376d6bff11ccef690addb4f9c40ab16dd20bec
Author: Haisheng Yuan 
AuthorDate: Fri May 15 08:01:16 2020 -0500

Following [CALCITE-3997] Remove TransformationRule from CalcMergeRule 
temporarily
---
 core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java 
b/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
index a65f81e..fc4a2e8 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/CalcMergeRule.java
@@ -35,7 +35,7 @@ import org.apache.calcite.tools.RelBuilderFactory;
  * {@link org.apache.calcite.rel.logical.LogicalCalc}, but expressed in terms 
of
  * the lower {@link org.apache.calcite.rel.logical.LogicalCalc}'s inputs.
  */
-public class CalcMergeRule extends RelOptRule implements TransformationRule {
+public class CalcMergeRule extends RelOptRule {
   //~ Static fields/initializers -
 
   public static final CalcMergeRule INSTANCE =



[calcite] branch master updated: [CALCITE-3997] Logical rules matched with physical operators but failed to handle traits

2020-05-14 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan 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 7be30db  [CALCITE-3997] Logical rules matched with physical operators 
but failed to handle traits
7be30db is described below

commit 7be30db36d449e0a7fcc76b7d4647e141f4bc72d
Author: Haisheng Yuan 
AuthorDate: Wed May 13 14:18:07 2020 -0500

[CALCITE-3997] Logical rules matched with physical operators but failed to 
handle traits

Logical transformation rule, only logical operator can be rule operand, and
only generate logical alternatives. It is only visible to VolcanoPlanner,
HepPlanner will ignore this interface. That means, in HepPlanner, the rule 
that
implements TransformationRule can still match with physical operator of
PhysicalNode and generate physical alternatives.  But in VolcanoPlanner,
TransformationRule doesn't match with physical operator that implements
PhysicalNode. It is NOT allowed to generate physical operators in
TransformationRule, unless you are using it in HepPlanner.

This will also fix issue CALCITE-3968.

Close #1976
---
 .../org/apache/calcite/plan/volcano/RuleQueue.java |  2 +-
 .../calcite/plan/volcano/VolcanoPlanner.java   | 10 ++
 .../calcite/plan/volcano/VolcanoRuleCall.java  |  2 +-
 .../rel/rules/AbstractJoinExtractFilterRule.java   |  3 +-
 .../rel/rules/AggregateCaseToFilterRule.java   |  3 +-
 .../AggregateExpandDistinctAggregatesRule.java |  3 +-
 .../rel/rules/AggregateExtractProjectRule.java |  3 +-
 .../rel/rules/AggregateFilterTransposeRule.java|  3 +-
 .../rel/rules/AggregateJoinJoinRemoveRule.java |  3 +-
 .../calcite/rel/rules/AggregateJoinRemoveRule.java |  2 +-
 .../rel/rules/AggregateJoinTransposeRule.java  |  2 +-
 .../calcite/rel/rules/AggregateMergeRule.java  |  2 +-
 .../rel/rules/AggregateProjectMergeRule.java   |  2 +-
 .../rules/AggregateProjectPullUpConstantsRule.java |  3 +-
 .../rel/rules/AggregateReduceFunctionsRule.java|  3 +-
 .../calcite/rel/rules/AggregateRemoveRule.java |  3 +-
 .../calcite/rel/rules/AggregateStarTableRule.java  |  2 +-
 .../rel/rules/AggregateUnionAggregateRule.java |  2 +-
 .../rel/rules/AggregateUnionTransposeRule.java |  2 +-
 .../calcite/rel/rules/AggregateValuesRule.java |  1 -
 .../apache/calcite/rel/rules/CalcMergeRule.java|  2 +-
 .../apache/calcite/rel/rules/CalcRemoveRule.java   |  1 -
 .../apache/calcite/rel/rules/CalcSplitRule.java|  2 +-
 .../apache/calcite/rel/rules/CoerceInputsRule.java |  2 +-
 .../apache/calcite/rel/rules/DateRangeRules.java   |  2 +-
 .../rel/rules/ExchangeRemoveConstantKeysRule.java  |  1 -
 .../rel/rules/FilterAggregateTransposeRule.java|  2 +-
 .../calcite/rel/rules/FilterCalcMergeRule.java |  2 +-
 .../calcite/rel/rules/FilterCorrelateRule.java |  2 +-
 .../apache/calcite/rel/rules/FilterJoinRule.java   |  2 +-
 .../apache/calcite/rel/rules/FilterMergeRule.java  |  1 -
 .../rel/rules/FilterMultiJoinMergeRule.java|  2 +-
 .../rel/rules/FilterProjectTransposeRule.java  |  2 +-
 .../rules/FilterRemoveIsNotDistinctFromRule.java   |  3 +-
 .../rel/rules/FilterSetOpTransposeRule.java|  2 +-
 .../rules/FilterTableFunctionTransposeRule.java|  3 +-
 .../apache/calcite/rel/rules/FilterToCalcRule.java |  2 +-
 .../calcite/rel/rules/IntersectToDistinctRule.java |  2 +-
 .../rel/rules/JoinAddRedundantSemiJoinRule.java|  3 +-
 .../calcite/rel/rules/JoinAssociateRule.java   |  2 +-
 .../apache/calcite/rel/rules/JoinCommuteRule.java  |  2 +-
 .../rel/rules/JoinProjectTransposeRule.java|  2 +-
 .../calcite/rel/rules/JoinPushExpressionsRule.java |  2 +-
 .../calcite/rel/rules/JoinPushThroughJoinRule.java |  2 +-
 .../rules/JoinPushTransitivePredicatesRule.java|  2 +-
 .../calcite/rel/rules/JoinToCorrelateRule.java |  2 +-
 .../calcite/rel/rules/JoinToMultiJoinRule.java |  2 +-
 .../calcite/rel/rules/JoinUnionTransposeRule.java  |  2 +-
 .../calcite/rel/rules/LoptOptimizeJoinRule.java|  2 +-
 .../org/apache/calcite/rel/rules/MatchRule.java|  2 +-
 .../rel/rules/MaterializedViewFilterScanRule.java  |  2 +-
 .../rel/rules/MultiJoinOptimizeBushyRule.java  |  2 +-
 .../calcite/rel/rules/ProjectCalcMergeRule.java|  2 +-
 .../rel/rules/ProjectCorrelateTransposeRule.java   |  2 +-
 .../rel/rules/ProjectFilterTransposeRule.java  |  2 +-
 .../rel/rules/ProjectJoinJoinRemoveRule.java   |  1 -
 .../calcite/rel/rules/ProjectJoinRemoveRule.java   |  1 -
 .../rel/rules/ProjectJoinTransposeRule.java|  2 +-
 .../apache/calcite/rel/rules/ProjectMergeRule.java |  8 -
 .../rel/rules/ProjectMultiJoinMergeRule.java   |  2 +-
 .../calcite/rel/rules/ProjectRemoveRule.java   |  1 -
 .../rel/rules/ProjectSetOpTransposeRule.java   |  2 +-
 .../rel

svn commit: r39386 - /release/calcite/KEYS

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 05:28:04 2020
New Revision: 39386

Log:
Add Haisheng's gpg key to KEYS file

Modified:
release/calcite/KEYS

Modified: release/calcite/KEYS
==
--- release/calcite/KEYS (original)
+++ release/calcite/KEYS Tue May 12 05:28:04 2020
@@ -1718,3 +1718,62 @@ M6VE9eTCmeemKyynxy6wYuO/LDEVdG01VLGOAUuY
 xvoHmaohmkOIrlVNTJE=
 =61x3
 -END PGP PUBLIC KEY BLOCK-
+pub   rsa4096 2019-05-01 [SC] [expires: 2024-04-29]
+  ECA9CF33AF2CEC28F3B66A5C3CD22ABAC50DDCEF
+uid   [ultimate] Haisheng Yuan 
+sig 33CD22ABAC50DDCEF 2019-05-01  Haisheng Yuan 
+sub   rsa4096 2019-05-01 [E] [expires: 2024-04-29]
+sig  3CD22ABAC50DDCEF 2019-05-01  Haisheng Yuan 
+
+-BEGIN PGP PUBLIC KEY BLOCK-
+
+mQINBFzJ4NQBEADDaWkEGfIrPWkfmvkQPTWBgrizLcv+cyrTA8tVjwSaENVrNssB
+hmNSz8d0NP96K4Hmf35VT8OUmReH27YBhFR57vwZ3F5Bf/IbP6Pr+th2jJja9hWr
+WfqScuNaJV7VGBUojVKZw98JJiC+/UkDLEiLgqrxSsOPTZf3Df+jPYNGN0QBhuzm
+ziKeubH4Kvqec9e3vXXwewqSoZ/nmKfmymD+xlJJM2sQjYX99cnmI+7HUhewOHkc
+UR2rhNYPEDDE2MAQe6TJi7hJp74h+a7FuDKOSFrsd50WbdJRkxzIaeVzkAZsD32r
+KQmykN9mwBVa+hzyCVshcaaIfW/Rz5K2QVqxdFtzqunolYD+RWXFbYKNHKyBrfR9
+IF6thl16vP7mhhgKH9vkcNyylL3uWTvDqYEDaE3tax8gVqVtRnap4nAm8D6tTxUG
+SfDfuXp9P/QH+4Fqdr/s3zzK37+Ao2PI4Rq5u5Jf/U49lnKNxP/OW4FsDeU1HXBz
+G/pbmltLW42fBss4U5orgCiRRfs/G7r/G/5HHxdQxDBBTCOD7mKLknQgJaKGHwvU
+YRB74FT/a43RfSi+85WhOP9bTz/duXOC0D1J4wQRMI+hQVz6lhc4To1o790z3FQz
+G327Mmwoc1bJa5r3dar2FeZODoNgANXCFDv6IS7ijbgSdK228DtHsZNHDQARAQAB
+tCBIYWlzaGVuZyBZdWFuIDxoeXVhbkBhcGFjaGUub3JnPokCVAQTAQgAPhYhBOyp
+zzOvLOwo87ZqXDzSKrrFDdzvBQJcyeDUAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQW
+AgMBAh4BAheAAAoJEDzSKrrFDdzvk/oQAIANrC2It5ZSE2PjvbN6oaRJMSR+1UWT
+vbMG6eAsgYjxR0C+QNW1/LqAK9Vz8PDXCfv5MyhM8ovxicDCNO+hNazqy5s1Ah7k
+xqJWAFa5LJ0GBD8Qs4TRrm+duKNRCB1wa74viS8YVev1XsS/eS6ttMVf+9MsIilZ
+q3ReZcW1Hs07xcGatKaGtM5BxyVin/wkzJweJiAHuxD0QwuKnP3zGi3jQS7Y/ejN
+l3TQLemxXevwC+caTenaO3AYrjVI4PT51klIQM1Yh5E8NOISR9NU3ALTY+9DuWPm
+hMQ+bUmHPTGP+Y7wkV/Qj1ABrIhuUeyLulDVLPyhOQRM19P676KTb7Rx2NVcKNfm
+JCWfkr0XpI3Y8u0nuougE58sBCD7I27S0L1Ut71JBmiP00zVUbHbDyC2HPCoi2bI
+XyYA5lj0D+ZAiYdVnJZIJOMAAEGF1saf+YlVXY/T7VE0rY9ngtlm4ERpHQQcp7ZX
+Mk4gNQ43iw3i02uQrmtVFtiswufRv7Vtti5Ewfoxme5WaoD8HOZHyPxQ+ffQN6Y1
+q+l38FK52dTE2wThxuFBb+d4ttBX7v+18KyX0Kajpwvaqa6VRfZ415AP3IDXrVo7
++kbx/fZFC1gVuzezJ3sjAizpmi7gmn2NwnPlTkcfbKdjqELDqkHKPiTtO1oaZjf6
+j7DIPOVayBlauQINBFzJ4NQBEADS3PCoucwfHz540db9N1XGoK+V+z8TcsqCOUX2
+ESm/MKI6ngzkqdmxm2EvSTAUlffAvOVMHVZAU5e7u/OVsrVZf4+P+W3cGZ5YxO06
+YAiZ8A4JcOeiQRje5V/t1SU8ZbU2ebaPXmm8tRG7g92LCOvGYqF9atgFg03jWtlu
+PJFBZd/ZRJMjlu//hrqa/NiwYG2z2jeLyHwu49qlPR8Cy5pB5gTxHgk8Ib4NtpfF
+Lp4ABliNssEkgk9gtBpUA2oUeDGaPQN3TmqQO2baeqtlj96PwFF0qGttLuTtU3pV
+5p8A9adnIjPisS7Zr7U7R9z4dHh8GMT+rZSWETeSbFLdqQ6a1KlPvZznNRvCTE69
+XCERbB18YgUOXVsaaVT/Vu7Uv2Ef+IYA38V4+fnp4Z8usWpWf4CprcKL9CGGRekK
+QPwbEoFOoUTpsZATxpYoeLs1P9kxIBamcOa2vPpf4+bjeIQWQh+07P+9zhg1uS25
+ShAn96qrfzHM4pNGQ79jdqRNtrvw0jdbFByC9vHA67t+zlYBhsse8GPSheuhsO5d
+MEtsGtuMnRyPUupmocEGp6GOWGohUibMAHZbPzL1gq6g5V3cn8giZ2p6bEy4Tj8j
+VPa/0AuvScBpQQm2ycRL7aHOxKcYYrUbLh3cccvSbsu7HvxRVbFsCmJKSQdn78k9
+jWJ6TQARAQABiQI8BBgBCAAmFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAlzJ4NQC
+GwwFCQlmAYAACgkQPNIqusUN3O/+mRAAiN9QkUF9RofyVUGARE5YjR9+llr7WaPR
+iSDO97a1tzuaxgOewMUBlbyPuOS4QnVrpA8dUy3cBkZE2uckBTlpWS6FbX8V8V/X
+sWcJxSwYxbN/5vKxVuO0lNxNL2zZuPzWd8Ftwy4v5YOk9k/CGqBJ3JYRTlnvxxEF
+M/o1A9EgxWe9dgeGWgV0Uu0xS6v35UeiYMFt+B505JFv6UBrL0Oavqjb0ohXQkYE
+KDUCG7cEslggdBW4Svq81f+vnf5HLHcpdTg8naZ7fe6Ue29q975VRZ37Nv8fmJYU
+Q2jJTU8cwCrjxGJUxn6EvrMMmajCsP6e/Z/0D/VXJzaA1sGcCevqlxHE2dcjC2ww
++BGnqN0eTtWtNYgDkB2i5y9z7U9nLt3576kV5gBetiLXxEyLIy3RbSo5hBWAumyA
+1ZBl0gcA97LOtATdQ/JxqllPiNW+BDmgHpYghsChPBgH9bMRIrAlC6A/8DhxPfK+
+nBcqnhE/icpI8qcBNdeynA1mvS/EpLFFOHAkT8mH8SOoIPQjl+2EfJojkamZdlJa
+ALJy0kp5mbm13exltww3oPUqV1SnHYnImAW7rSMApKpvQccRk83CZ0nHzoRPf6Ct
+ipPKWR3S0Vrztlzu17q+bB3PgtAQt1FrSg6UB3XZoMT/GorfXKcF+R92zhslBL/x
+MIU6EJiQuZs=
+=bRKv
+-END PGP PUBLIC KEY BLOCK-




svn commit: r39384 - in /dev/calcite/apache-calcite-1.23.0-rc0: apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 04:32:12 2020
New Revision: 39384

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc0 to dev area

Modified:
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512

Modified: dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
==
(empty)

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc
==
(empty)

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512
==
(empty)




svn commit: r39383 - in /dev/calcite/apache-calcite-1.23.0-rc0: apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 04:22:00 2020
New Revision: 39383

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc0 to dev area

Modified:
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512

Modified: dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
==
(empty)

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc
==
--- dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
(original)
+++ dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
Tue May 12 04:22:00 2020
@@ -1,17 +1,17 @@
 -BEGIN PGP SIGNATURE-
 Version: BCPG v1.64
 
-iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66GmIACgkQPNIqusUN
-3O9QuA//TjswdVFGspznvQb5YIorGWZm9oi4/nBX960nwbLjCvY63MLwbR3loEnN
-ayfjg4dViTLulLK3Ag3eyTdEx/LgUgrZCsZUGaVsZB3OFvrPB29RuTaUW/p3sMkI
-ehcHxh9RyiWOra5sX8rJFPqhYpsAYMSEsAbdTlvBBzBAfl28Ar70vcuP12lkD1G0
-56i5M/q4ypj/URMaTuz+35mSwlISs/5TTacnlyLeZj5MtN3/d+LZi2d1t2cMSbZN
-fj3oxHbrpMFqwNtmxjAEaXKs320o97MBe1fFpKS4A2i9IfwHl68W2NGMM59WBKTO
-/OWN8nlX4QpC7Ltmt+1Wnh+ZN/6Yh+pIok9sRfyWCdUl39OcArIlo/MlcDPB0HDh
-exHrp4lzl0H8MXURhN6cZYU4qbNbTmpSpskPXvlRkEBucPE9kUH+I+tH1q7eR8w6
-PvRVI45pgzLB20g+lfpYEqFXIzyPKovgJi4+jQVdR7S0Tu+CUngEXeUNz3mZoJb9
-ug0WqGEa35wDTkpmFOxmQOQSbWox1PtUCvQPn5HDNSx2ELWp1GqClhVX4AkfziSD
-aigun6Zz16dhvz0rv6qVwuHd2oQb9UBW2WXD58iDjmMbEnjStNNdkBP+HF3TPuJU
-LklPuOF2mqCTbU0o6V6RouWXiemxDTZpzYmsYejrnsI2TgjPrNE=
-=OQr+
+iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66JCgACgkQPNIqusUN
+3O8eoRAAn3f7r8PnwfCfknQZBd+X9dRxd3nacihSB/XBEq81NwsRHR79kikjd12n
+x6RWeHyAWIJRg4Eu4CtGR0EDzYHDJxo9A8HLnjDKFuB0mHeTwyV82OPKpcy0K6KQ
+wymsKLgiGpwYmIHDEseWbaCS6ko3ap5LtQNB1sMO32dX8+XfSbVoiRLBkjFnQ8K9
+HfIWgtQdEMCBsQTBNIDw/8omTB9AoW95HHZXLh5Y6hymsjMwfbAJ0ZFyR5OX47+p
+dXV/KZViSwKMY0X4bKNsMjk5f/c9Z3LNtcoSmjemTkWa2AHXQwYITJv24r4eKIZC
+KYFF+wzq6ZLtiwflxZGAugzTH5kIzNEaKc9QGS4iUBcKyomXl5riNLVeO790O5Ao
+9E3WKLjAyUwxMnpBnUiuOebslymnWBIT85hCagWQHoQtN0Ip4AOYDsU6MzWfDuu7
+ozO20xIGjG5J48CRv7WbEYGxGhf1UhKaL6gkEi0mtHzpN2UYCOXI3zAoeXtN6kBH
+TVHcppkhzZTaX9/zZjS/RSdCkBqlqxRzd4d6zNnbPxY8TMYFZ2jFzHwjnttFvKcL
+9Rlzrq6nc3C3zcJXfsXDfOy8wG4DqjAqnKDYUMInNIHPHHjfrEQayxUfumqEUoGO
+4rkwl+wHQpOxqasTlHaN6cVoopP3sNn7Mb3qTIZGH4umO4NKJ2c=
+=xpeX
 -END PGP SIGNATURE-

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512
==
(empty)




svn commit: r39382 - in /dev/calcite/apache-calcite-1.23.0-rc0: apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 03:40:22 2020
New Revision: 39382

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc0 to dev area

Modified:
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512

Modified: dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
==
Binary files 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz 
(original) and 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz Tue May 
12 03:40:22 2020 differ

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc
==
--- dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
(original)
+++ dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
Tue May 12 03:40:22 2020
@@ -1,17 +1,17 @@
 -BEGIN PGP SIGNATURE-
 Version: BCPG v1.64
 
-iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66Cq0ACgkQPNIqusUN
-3O8bJA//Vi1skdp9JEP3NejAEOwnwS7R/tk9DBkW8lCphZJU39PqJ0CJu07jD0SD
-u4DgWrQ0wXBKr79f4BrjID6Zs29DTfU247qlGqa/zYACBV9MWD+f3+0gHydr17IC
-7SBlWBpB1dsvWznDZTEOlmn5Ee4qxyTFxnPMWDsSX3YyXeSMUYv/yIeUVQ5FEs6K
-pCMx9xqKh2fUgwJCv0iw+nXO7mVNYgGGOnbjz/rO8CITWc064Zdb51iRIkIzWSjX
-cDeJglmCm1rInnr/or/ugxjmBA+cEAjfotqrCRfubu+zhpqBEnOV8WUUB0RdeocH
-4ur2/repVhLo7RJc5UIMhDHpzlK5GCUvfssHpgofz9CF4O6NLxr0KVBuekzTzUNN
-+USjP+x+oiFT6BegR5BLScE1l6j3Ci10jbRCnxZZXbWX1gbsh1KnBdvoIQkcX1tz
-LfcnUAhnMoL9vRgsYvrSgCQ5F1dGlp3Pb1rh6IbcI7cKrzgNDajf+dG/ehwiQqAW
-dq4d+EUYDUEBHY6CDJrmQrxMSLJu37b6SLiLJVpQVbjnyKXCUcix8XrIhzKKvHVw
-6+AoyaGPt6QOAXLZItz15c0Uyh025FbVLAcs2nMFB9z//UMNV0IFyBArC1ZxGrKR
-yDDuFLHv7z9c6kP0oAcCEtwstKz/WhluzvdFvYHPvX5XeSGWM2M=
-=Flxk
+iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66GmIACgkQPNIqusUN
+3O9QuA//TjswdVFGspznvQb5YIorGWZm9oi4/nBX960nwbLjCvY63MLwbR3loEnN
+ayfjg4dViTLulLK3Ag3eyTdEx/LgUgrZCsZUGaVsZB3OFvrPB29RuTaUW/p3sMkI
+ehcHxh9RyiWOra5sX8rJFPqhYpsAYMSEsAbdTlvBBzBAfl28Ar70vcuP12lkD1G0
+56i5M/q4ypj/URMaTuz+35mSwlISs/5TTacnlyLeZj5MtN3/d+LZi2d1t2cMSbZN
+fj3oxHbrpMFqwNtmxjAEaXKs320o97MBe1fFpKS4A2i9IfwHl68W2NGMM59WBKTO
+/OWN8nlX4QpC7Ltmt+1Wnh+ZN/6Yh+pIok9sRfyWCdUl39OcArIlo/MlcDPB0HDh
+exHrp4lzl0H8MXURhN6cZYU4qbNbTmpSpskPXvlRkEBucPE9kUH+I+tH1q7eR8w6
+PvRVI45pgzLB20g+lfpYEqFXIzyPKovgJi4+jQVdR7S0Tu+CUngEXeUNz3mZoJb9
+ug0WqGEa35wDTkpmFOxmQOQSbWox1PtUCvQPn5HDNSx2ELWp1GqClhVX4AkfziSD
+aigun6Zz16dhvz0rv6qVwuHd2oQb9UBW2WXD58iDjmMbEnjStNNdkBP+HF3TPuJU
+LklPuOF2mqCTbU0o6V6RouWXiemxDTZpzYmsYejrnsI2TgjPrNE=
+=OQr+
 -END PGP SIGNATURE-

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512
==
--- 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512 
(original)
+++ 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512 
Tue May 12 03:40:22 2020
@@ -1 +1 @@
-719e85f7b6fe563958186e644c273e45b01cbd8fa524caea758948419a748f11a51c4fac527133367a921b5c9242f2d4c6ce5a977a44c2e84c40db65eba64646
 *apache-calcite-1.23.0-src.tar.gz
+7482b0bb76e672a15bbe846f2dbdc125bd0f3d8a32abf0ea9159b5db0ab2a2d1182e19b408098ecd68d7cc9ff5d7812ea0b33e4aeac818d191b695d437fa1a94
 *apache-calcite-1.23.0-src.tar.gz




[calcite] branch branch-1.23 updated (0c0f143 -> edc37c0)

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


 discard 0c0f143  [CALCITE-3989] Release Calcite 1.23.0
 new edc37c0  [CALCITE-3989] Release Calcite 1.23.0

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (0c0f143)
\
 N -- N -- N   refs/heads/branch-1.23 (edc37c0)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 site/_docs/history.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



[calcite] 01/01: [CALCITE-3989] Release Calcite 1.23.0

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit edc37c0a21344a48b15877788e082c8acdc7b030
Author: Haisheng Yuan 
AuthorDate: Mon May 11 18:48:12 2020 -0500

[CALCITE-3989] Release Calcite 1.23.0
---
 README|   2 +-
 site/_docs/history.md | 150 +-
 site/_docs/howto.md   |   6 +-
 3 files changed, 151 insertions(+), 7 deletions(-)

diff --git a/README b/README
index 7eeca3a..b03b439 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Calcite release 1.22.0
+Apache Calcite release 1.23.0
 
 This is a source or binary distribution of Apache Calcite.
 
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 04dc02f..5f1b5cc 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,9 +28,20 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ under development
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-12
 {: #v1-23-0}
 
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as general improvements
+and bug-fixes. Among others, it is worth highlighting the following.
+
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
+* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
 Guava versions 19.0 to 28.2-jre; Apache Flink 1.10.0;
@@ -38,8 +49,141 @@ other software versions as specified in gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
-  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
+
+ New features
+
+* [https://issues.apache.org/jira/browse/CALCITE-3984;>CALCITE-3984] 
Support `Exchange` operator in `RelFieldTrimmer` (Xu Zhaohui)
+* [https://issues.apache.org/jira/browse/CALCITE-3971;>CALCITE-3971] 
Support `Calc` in `RelMdColumnOrigins` (Xu ZhaoHui)
+* [https://issues.apache.org/jira/browse/CALCITE-3921;>CALCITE-3921] 
Support `TableModify` json serialization and deserialization (Wang Yanlin)
+* [https://issues.apache.org/jira/browse/CALCITE-3938;>CALCITE-3938] 
Support `LogicalCalc` in `RelShuttle` (dz)
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3880;>CALCITE-3880] Add 
`SortExchange` support to `RelFieldTrimmer` (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3867;>CALCITE-3867] 
Support `RelDistribution` json serialization (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3718;>CALCITE-3718] 
Support `Intersect` and `Minus` in `Bindables` (xzh)
+* [https://issues.apache.org/jira/browse/CALCITE-3789;>CALCITE-3789] 
Support Presto style `unnest` with items alias (Will Yu)
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3833;>CALCITE-3833] 
Support `SemiJoin` in `EnumerableMerg

svn commit: r39381 - in /dev/calcite/apache-calcite-1.23.0-rc0: apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 02:33:21 2020
New Revision: 39381

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc0 to dev area

Modified:
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512

Modified: dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
==
(empty)

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc
==
--- dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
(original)
+++ dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
Tue May 12 02:33:21 2020
@@ -1,17 +1,17 @@
 -BEGIN PGP SIGNATURE-
 Version: BCPG v1.64
 
-iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66BQEACgkQPNIqusUN
-3O9rtA//TeLFYYw2XIZlBf/s8ttqQjmqXnajbBaKgwc+K4Rkc6ZtHuCKU3kxV077
-PkLqHLDn1h+aW9Z+1d05ZCfhvwNLWhi4PmewbQejk7rXbHlRaxH7q/FwPnJ93RUe
-mX9wvzutz0WJb9eirYyuJl6DqJA87c5H5l92dS1EmuKpWaAe9zV5ZXzbuH8J4kOU
-IXqI4xkC9zPmcnvFZZN9dRXtIW5XP6ncRAd/+SmOKkx633TTMpojW94mlYFaiAk4
-uSO3hFbH+VmuJnh2r0EHM+eUMiZ6w0MtVP756vg3xXXhetWJ5A4B8+L6nRGQHMQ+
-3jEB6PVD9RL49Ezb7uNRh6DIhVGX3RBsJorfmYc44hE3amQDY3dbrRRjYUmJ6OnO
-BkrvC2tX/y9Rpy3hjAmYa/is6rKS1cLUpwa8gvxE/EbPb/4zy/SmAvTnVgHyxVOm
-msdagHHCdCzrx45rtmk4Sx7zPJNcei/FuLS+5c1tqk76yZsOCUEUBDUmtDNyglPE
-t3YdVBqd2Q2rNAwMrIqd6Ca2EF9WOGg37203hra+6HivMgdgwzCo+FPKE44sQ92r
-SJp08nTVPkQGLteT6bar711XOAs8S8R+DtDZtaSGRqLGVBuGG11OOJ1OAJYAA1kY
-bQpJ6wBh54aFsRDSfBtIFY8gASLuDSbtMBTkrtAS2P3/vx88PpE=
-=kR7f
+iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66Cq0ACgkQPNIqusUN
+3O8bJA//Vi1skdp9JEP3NejAEOwnwS7R/tk9DBkW8lCphZJU39PqJ0CJu07jD0SD
+u4DgWrQ0wXBKr79f4BrjID6Zs29DTfU247qlGqa/zYACBV9MWD+f3+0gHydr17IC
+7SBlWBpB1dsvWznDZTEOlmn5Ee4qxyTFxnPMWDsSX3YyXeSMUYv/yIeUVQ5FEs6K
+pCMx9xqKh2fUgwJCv0iw+nXO7mVNYgGGOnbjz/rO8CITWc064Zdb51iRIkIzWSjX
+cDeJglmCm1rInnr/or/ugxjmBA+cEAjfotqrCRfubu+zhpqBEnOV8WUUB0RdeocH
+4ur2/repVhLo7RJc5UIMhDHpzlK5GCUvfssHpgofz9CF4O6NLxr0KVBuekzTzUNN
++USjP+x+oiFT6BegR5BLScE1l6j3Ci10jbRCnxZZXbWX1gbsh1KnBdvoIQkcX1tz
+LfcnUAhnMoL9vRgsYvrSgCQ5F1dGlp3Pb1rh6IbcI7cKrzgNDajf+dG/ehwiQqAW
+dq4d+EUYDUEBHY6CDJrmQrxMSLJu37b6SLiLJVpQVbjnyKXCUcix8XrIhzKKvHVw
+6+AoyaGPt6QOAXLZItz15c0Uyh025FbVLAcs2nMFB9z//UMNV0IFyBArC1ZxGrKR
+yDDuFLHv7z9c6kP0oAcCEtwstKz/WhluzvdFvYHPvX5XeSGWM2M=
+=Flxk
 -END PGP SIGNATURE-

Modified: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512
==
(empty)




svn commit: r39380 - in /dev/calcite/apache-calcite-1.23.0-rc0: ./ apache-calcite-1.23.0-src.tar.gz apache-calcite-1.23.0-src.tar.gz.asc apache-calcite-1.23.0-src.tar.gz.sha512

2020-05-11 Thread hyuan
Author: hyuan
Date: Tue May 12 02:09:07 2020
New Revision: 39380

Log:
Uploading release candidate Apache Calcite calcite-1.23.0-rc0 to dev area

Added:
dev/calcite/apache-calcite-1.23.0-rc0/
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc

dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512

Added: dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz
==
Binary files 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz (added) 
and dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz Tue 
May 12 02:09:07 2020 differ

Added: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc
==
--- dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
(added)
+++ dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.asc 
Tue May 12 02:09:07 2020
@@ -0,0 +1,17 @@
+-BEGIN PGP SIGNATURE-
+Version: BCPG v1.64
+
+iQIzBAABCAAdFiEE7KnPM68s7CjztmpcPNIqusUN3O8FAl66BQEACgkQPNIqusUN
+3O9rtA//TeLFYYw2XIZlBf/s8ttqQjmqXnajbBaKgwc+K4Rkc6ZtHuCKU3kxV077
+PkLqHLDn1h+aW9Z+1d05ZCfhvwNLWhi4PmewbQejk7rXbHlRaxH7q/FwPnJ93RUe
+mX9wvzutz0WJb9eirYyuJl6DqJA87c5H5l92dS1EmuKpWaAe9zV5ZXzbuH8J4kOU
+IXqI4xkC9zPmcnvFZZN9dRXtIW5XP6ncRAd/+SmOKkx633TTMpojW94mlYFaiAk4
+uSO3hFbH+VmuJnh2r0EHM+eUMiZ6w0MtVP756vg3xXXhetWJ5A4B8+L6nRGQHMQ+
+3jEB6PVD9RL49Ezb7uNRh6DIhVGX3RBsJorfmYc44hE3amQDY3dbrRRjYUmJ6OnO
+BkrvC2tX/y9Rpy3hjAmYa/is6rKS1cLUpwa8gvxE/EbPb/4zy/SmAvTnVgHyxVOm
+msdagHHCdCzrx45rtmk4Sx7zPJNcei/FuLS+5c1tqk76yZsOCUEUBDUmtDNyglPE
+t3YdVBqd2Q2rNAwMrIqd6Ca2EF9WOGg37203hra+6HivMgdgwzCo+FPKE44sQ92r
+SJp08nTVPkQGLteT6bar711XOAs8S8R+DtDZtaSGRqLGVBuGG11OOJ1OAJYAA1kY
+bQpJ6wBh54aFsRDSfBtIFY8gASLuDSbtMBTkrtAS2P3/vx88PpE=
+=kR7f
+-END PGP SIGNATURE-

Added: 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512
==
--- 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512 
(added)
+++ 
dev/calcite/apache-calcite-1.23.0-rc0/apache-calcite-1.23.0-src.tar.gz.sha512 
Tue May 12 02:09:07 2020
@@ -0,0 +1 @@
+719e85f7b6fe563958186e644c273e45b01cbd8fa524caea758948419a748f11a51c4fac527133367a921b5c9242f2d4c6ce5a977a44c2e84c40db65eba64646
 *apache-calcite-1.23.0-src.tar.gz




[calcite] 01/01: [CALCITE-3989] Release Calcite 1.23.0

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 0c0f1436add16d4dd17e23a4744bd81e07e871c2
Author: Haisheng Yuan 
AuthorDate: Mon May 11 18:48:12 2020 -0500

[CALCITE-3989] Release Calcite 1.23.0
---
 README|   2 +-
 site/_docs/history.md | 150 +-
 site/_docs/howto.md   |   6 +-
 3 files changed, 151 insertions(+), 7 deletions(-)

diff --git a/README b/README
index 7eeca3a..b03b439 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Apache Calcite release 1.22.0
+Apache Calcite release 1.23.0
 
 This is a source or binary distribution of Apache Calcite.
 
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 04dc02f..40a66c0 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,9 +28,20 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ under development
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-12
 {: #v1-23-0}
 
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as general improvements
+and bug-fixes. Among others, it is worth highlighting the following.
+
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
 Guava versions 19.0 to 28.2-jre; Apache Flink 1.10.0;
@@ -38,8 +49,141 @@ other software versions as specified in gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
-  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
+
+ New features
+
+* [https://issues.apache.org/jira/browse/CALCITE-3984;>CALCITE-3984] 
Support `Exchange` operator in `RelFieldTrimmer` (Xu Zhaohui)
+* [https://issues.apache.org/jira/browse/CALCITE-3971;>CALCITE-3971] 
Support `Calc` in `RelMdColumnOrigins` (Xu ZhaoHui)
+* [https://issues.apache.org/jira/browse/CALCITE-3921;>CALCITE-3921] 
Support `TableModify` json serialization and deserialization (Wang Yanlin)
+* [https://issues.apache.org/jira/browse/CALCITE-3938;>CALCITE-3938] 
Support `LogicalCalc` in `RelShuttle` (dz)
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3880;>CALCITE-3880] Add 
`SortExchange` support to `RelFieldTrimmer` (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3867;>CALCITE-3867] 
Support `RelDistribution` json serialization (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3718;>CALCITE-3718] 
Support `Intersect` and `Minus` in `Bindables` (xzh)
+* [https://issues.apache.org/jira/browse/CALCITE-3789;>CALCITE-3789] 
Support Presto style `unnest` with items alias (Will Yu)
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3833;>CALCITE-3833] 
Support `SemiJoin` in `EnumerableMerg

[calcite] branch branch-1.23 updated (bf3ca03 -> 0c0f143)

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


 discard bf3ca03  [CALCITE-3989] Release Calcite 1.23.0
 new 0c0f143  [CALCITE-3989] Release Calcite 1.23.0

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (bf3ca03)
\
 N -- N -- N   refs/heads/branch-1.23 (0c0f143)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



[calcite] 01/01: [CALCITE-3989] Release Calcite 1.23.0

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit bf3ca037c7bc2c9889121e24e2a30e0420a4f098
Author: Haisheng Yuan 
AuthorDate: Mon May 11 18:48:12 2020 -0500

[CALCITE-3989] Release Calcite 1.23.0
---
 site/_docs/history.md | 150 +-
 site/_docs/howto.md   |   6 +-
 2 files changed, 150 insertions(+), 6 deletions(-)

diff --git a/site/_docs/history.md b/site/_docs/history.md
index 04dc02f..40a66c0 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -28,9 +28,20 @@ For a full list of releases, see
 Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
-## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ under development
+## https://github.com/apache/calcite/releases/tag/calcite-1.23.0;>1.23.0 
/ 2020-05-12
 {: #v1-23-0}
 
+This release comes two months after 1.22.0. It includes more than 100 resolved
+issues, comprising a lot of new features as well as general improvements
+and bug-fixes. Among others, it is worth highlighting the following.
+
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
Boost `VolcanoPlanner` performance by removing rule match and subset importance
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-2970;>CALCITE-2970] 
Improve `VolcanoPlanner` performance when abstract converter is enabled
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+
 Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
 using Oracle JDK 8, 9, 10, 11, 12, 13, 14 and OpenJDK 8, 9, 10, 11, 12, 13, 14;
 Guava versions 19.0 to 28.2-jre; Apache Flink 1.10.0;
@@ -38,8 +49,141 @@ other software versions as specified in gradle.properties.
 
  Breaking Changes
 
-* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877]
-  In `RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3877;>CALCITE-3877] In 
`RexWindow`, make fields `upperBound` and `lowerBound` not-nullable
+* [https://issues.apache.org/jira/browse/CALCITE-3868;>CALCITE-3868] 
Remove redundant `ruleSet`(protected)and `ruleNames`(private) in 
`VolcanoPlanner`
+* [https://issues.apache.org/jira/browse/CALCITE-3753;>CALCITE-3753] 
`VolcanoPlanner` flags `impatient` and `ambitious` are removed, alternatively 
use `checkCancel()` to achieve `impatient` mode
+
+ New features
+
+* [https://issues.apache.org/jira/browse/CALCITE-3984;>CALCITE-3984] 
Support `Exchange` operator in `RelFieldTrimmer` (Xu Zhaohui)
+* [https://issues.apache.org/jira/browse/CALCITE-3971;>CALCITE-3971] 
Support `Calc` in `RelMdColumnOrigins` (Xu ZhaoHui)
+* [https://issues.apache.org/jira/browse/CALCITE-3921;>CALCITE-3921] 
Support `TableModify` json serialization and deserialization (Wang Yanlin)
+* [https://issues.apache.org/jira/browse/CALCITE-3938;>CALCITE-3938] 
Support `LogicalCalc` in `RelShuttle` (dz)
+* [https://issues.apache.org/jira/browse/CALCITE-3896;>CALCITE-3896] 
`VolcanoPlanner` supports top down trait request and trait enforcement without 
abstract converter
+* [https://issues.apache.org/jira/browse/CALCITE-3880;>CALCITE-3880] Add 
`SortExchange` support to `RelFieldTrimmer` (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3867;>CALCITE-3867] 
Support `RelDistribution` json serialization (Krisztian Kasa)
+* [https://issues.apache.org/jira/browse/CALCITE-3780;>CALCITE-3780] 
Support `SESSION` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3737;>CALCITE-3737] 
Support `HOP` Table function (Rui Wang)
+* [https://issues.apache.org/jira/browse/CALCITE-3718;>CALCITE-3718] 
Support `Intersect` and `Minus` in `Bindables` (xzh)
+* [https://issues.apache.org/jira/browse/CALCITE-3789;>CALCITE-3789] 
Support Presto style `unnest` with items alias (Will Yu)
+* [https://issues.apache.org/jira/browse/CALCITE-2157;>CALCITE-2157] 
ClickHouse dialect implementation (Chris Baynes)
+* [https://issues.apache.org/jira/browse/CALCITE-3833;>CALCITE-3833] 
Support `SemiJoin` in `EnumerableMergeJoin`
+* [https://issues.apache.org/jira/browse/CALCITE-3684;>CALCITE-3684] 
Support `CONCAT` for variable arguments (Wenhui Tang)
+* [https://issues.apache.org/jira/browse/CALCITE-3285;>CALCITE-3285] 
`EnumerableMergeJoin` support non-equi join conditions

[calcite] branch branch-1.23 created (now bf3ca03)

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch branch-1.23
in repository https://gitbox.apache.org/repos/asf/calcite.git.


  at bf3ca03  [CALCITE-3989] Release Calcite 1.23.0

This branch includes the following new commits:

 new bf3ca03  [CALCITE-3989] Release Calcite 1.23.0

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[calcite] branch master updated (888e879 -> 2e30293)

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 888e879  [CALCITE-3969] Trait keys remapping may throw exception when 
some trait key is not mapped (Roman Kondakov)
 add 2e30293  The release tag should be 'calcite-N.N' not 'vN.N'

No new revisions were added by this update.

Summary of changes:
 build.gradle.kts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



[calcite] branch master updated (de3bef9 -> 888e879)

2020-05-11 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from de3bef9  [CALCITE-3982] Simplify FilterMergeRule to rely on RelBuilder 
instead of RexProgram
 add 888e879  [CALCITE-3969] Trait keys remapping may throw exception when 
some trait key is not mapped (Roman Kondakov)

No new revisions were added by this update.

Summary of changes:
 .../java/org/apache/calcite/plan/RelTrait.java |  13 +++
 .../org/apache/calcite/rel/RelCollationImpl.java   |  18 
 .../org/apache/calcite/rel/RelDistribution.java|  18 
 .../org/apache/calcite/rel/RelDistributions.java   |  28 --
 .../rel/rules/ProjectJoinTransposeRule.java|   9 +-
 .../rel/rules/SortProjectTransposeRule.java|   4 +-
 .../main/java/org/apache/calcite/rex/RexUtil.java  |   6 +-
 .../java/org/apache/calcite/util/Permutation.java  |  12 +--
 .../org/apache/calcite/util/mapping/Mappings.java  |  79 +++-
 .../org/apache/calcite/rel/RelCollationTest.java   |  60 -
 .../apache/calcite/rel/RelDistributionTest.java|  46 ++
 .../apache/calcite/util/mapping/MappingTest.java   | 100 -
 12 files changed, 323 insertions(+), 70 deletions(-)



[calcite] branch master updated (916f1e7 -> 2730b4b)

2020-05-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


from 916f1e7  Disable time-wasting test
 add 2730b4b  [CALCITE-3984] Support exchange operator in RelFieldTrimmer 
(Xu Zhaohui)

No new revisions were added by this update.

Summary of changes:
 .../apache/calcite/sql2rel/RelFieldTrimmer.java| 39 ++
 .../calcite/sql2rel/RelFieldTrimmerTest.java   | 59 ++
 2 files changed, 98 insertions(+)



[calcite] branch master updated (bc56640 -> 916f1e7)

2020-05-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


omit bc56640  Disable time-wasting test
omit 8ecec29  [CALCITE-3983] Add utility methods to RelTraitSet
omit bb48485  [CALCITE-3896] Top down trait request
 new 9c31d9e  [CALCITE-3896] Top down trait request
 new ef28c9b  [CALCITE-3983] Add utility methods to RelTraitSet
 new 916f1e7  Disable time-wasting test

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (bc56640)
\
 N -- N -- N   refs/heads/master (916f1e7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:



[calcite] 03/03: Disable time-wasting test

2020-05-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 916f1e76da4ef5ee2de80384b4aaa61e5129b3a8
Author: Haisheng Yuan 
AuthorDate: Sun May 10 18:54:01 2020 -0500

Disable time-wasting test
---
 plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java 
b/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java
index 8c523ec..31310e6 100644
--- a/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java
+++ b/plus/src/test/java/org/apache/calcite/adapter/tpch/TpchTest.java
@@ -755,6 +755,7 @@ class TpchTest {
   + "order by\n"
   + "  cntrycode");
 
+  @Disabled("it's wasting time")
   @Test void testRegion() {
 with()
 .query("select * from tpch.region")
@@ -911,6 +912,7 @@ class TpchTest {
 
   // a bit slow
   @Timeout(value = 10, unit = TimeUnit.MINUTES)
+  @Disabled("Too slow, more than 5 min")
   @Test void testQuery19() {
 checkQuery(19);
   }



[calcite] 01/03: [CALCITE-3896] Top down trait request

2020-05-10 Thread hyuan
This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 9c31d9e83dc718800a36f7719534f9f74633c8a7
Author: Haisheng Yuan 
AuthorDate: Wed Apr 29 09:56:19 2020 -0500

[CALCITE-3896] Top down trait request

1. Top-down trait request
2. Bottom-up trait derivation
3. Trait enforcement without AbstractConverter

How to use?

1. Enable top-down optimization by setting 
{VolcanoPlanner#setTopDownOpt(boolean)}
or add 'calcite.planner.topdown.opt=true' to saffron.properties config file.

2. Let your convention's rel interface extends {PhysicalNode}, see
{EnumerableRel} as an example.

3. Each physical operator overrides any one of the two methods:
{PhysicalNode#passThrough(RelTraitSet)} or
{PhysicalNode#passThroughTraits(RelTraitSet)} depending on your needs.

4. Choose derive mode for each physical operator by overriding
{PhysicalNode#getDeriveMode()}.

5. If the derive mode is {DeriveMode#OMAKASE}, override method
{PhysicalNode#derive(List)} in the physical operator, otherwise, override
{PhysicalNode#derive(RelTraitSet, int)} or
{PhysicalNode#deriveTraits(RelTraitSet, int)}.

6. Mark your enforcer operator by overriding {RelNode#isEnforcer()}, see
{Sort#isEnforcer()} as an example. This is important, because it can help
{VolcanoPlanner} avoid unnecessary trait propagation and derivation, 
therefore
improve optimization efficiency.

7. Implement {Convention#enforce(RelNode, RelTraitSet)} in your convention,
which generates appropriate physical enforcer. See
{EnumerableConvention#enforce(RelNode, RelTraitSet)} as example. Simply 
return
null if you don't want physical trait enforcement.

How does it work?

Let S# denote the seed physical operator in a RelSet after logical and 
physical
rules transformation, P# denote the physical operator generated by passing 
down
parent trait requirements, D# denote the physical operator generated by
deriving from child delivered traitSets.

The initial rel list state in a RelSet is as follows:
cursor
  |
  V
 S1, S2

When we create a task for RelSubset1, the task will immediately pass the
subset's traitSet to seed operators, S1 and S2, now we have:
cursor
  |
  V
 S1, S2, P1, P2

The subset task will create a optimization task for the relnode pointed by
cursor, and move cursor to next available physical operator S2. In the task 
for
S1, it will continue optimize its child nodes, which are RelSubsets. After
child inputs optimization is finished, S1 will derive new relnodes from
delivered subsets in input RelSet. Once task for S1 is completed, we have:
cursor
  |
  V
 S1, S2, P1, P2, D1

The subset task continues scheduling task for S2, P1... until there is no 
more
relnode created for the RelSet, then we have:
cursor
  |
  V
 S1, S2, P1, P2, D1, D2, D3, null

When a task for another RelSubset2 is created, the task will try to pass 
down
the subset's traitSet to seed operator S1 and S2, now the RelSet looks like:
cursor
  |
  V
 S1, S2, P1, P2, D1, D2, D3, P3, P4

The process continues till there is no more subsets or relnodes created for 
the
RelSet.

See https://t.ly/MmaF for discussion.

Close #1953
---
 .../adapter/enumerable/EnumerableConvention.java   |  20 ++
 .../adapter/enumerable/EnumerableMergeJoin.java| 106 ++-
 .../calcite/adapter/enumerable/EnumerableRel.java  |  23 +-
 .../adapter/enumerable/EnumerableRules.java|   3 +
 .../enumerable/EnumerableSortedAggregate.java  |  96 ++
 .../enumerable/EnumerableSortedAggregateRule.java  |  61 
 .../calcite/config/CalciteSystemProperty.java  |   9 +
 .../java/org/apache/calcite/plan/Convention.java   |  20 ++
 .../java/org/apache/calcite/plan/DeriveMode.java   |  59 
 .../apache/calcite/plan/volcano/OptimizeTask.java  | 344 +
 .../org/apache/calcite/plan/volcano/RelSet.java|  78 -
 .../org/apache/calcite/plan/volcano/RelSubset.java |   5 +
 .../calcite/plan/volcano/VolcanoPlanner.java   |  44 +++
 .../java/org/apache/calcite/rel/PhysicalNode.java  | 154 +
 .../java/org/apache/calcite/rel/RelCollations.java |  11 +
 .../apache/calcite/util/trace/CalciteTrace.java|   7 +
 .../plan/volcano/CollationConversionTest.java  |   1 +
 .../apache/calcite/plan/volcano/PlannerTests.java  |   5 +
 .../calcite/plan/volcano/TraitConversionTest.java

  1   2   3   >