Skip to content
Permalink
Browse files
IGNITE-14903 Bump calcite version up to 1.27.0 (#198)
  • Loading branch information
zstan committed Jul 6, 2021
1 parent 7f82358 commit c5fb1665927dbba2ee3690d71ea430f07d4647e7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 17 deletions.
@@ -991,10 +991,10 @@ private static class MethodImplementor extends AbstractRexCallImplementor {
final Expression expression;
Class clazz = method.getDeclaringClass();
if (Modifier.isStatic(method.getModifiers()))
expression = EnumUtils.call(clazz, method.getName(), argValueList);
expression = EnumUtils.call(null, clazz, method.getName(), argValueList);
else {
expression = EnumUtils.call(clazz, method.getName(),
Util.skip(argValueList, 1), argValueList.get(0));
expression = EnumUtils.call(argValueList.get(0), clazz, method.getName(),
Util.skip(argValueList, 1));
}
return expression;
}
@@ -1060,7 +1060,7 @@ else if (exprVal == SqlJsonEmptyOrError.ERROR) {
newOperands.add(errorBehavior);
newOperands.add(defaultValueOnError);
Class clazz = method.getDeclaringClass();
final Expression expression = EnumUtils.call(clazz, method.getName(), newOperands);
final Expression expression = EnumUtils.call(null, clazz, method.getName(), newOperands);

final Type returnType =
translator.typeFactory.getJavaClass(call.getType());
@@ -1094,6 +1094,7 @@ private static class MethodNameImplementor extends AbstractRexCallImplementor {
@Override Expression implementSafe(RexToLixTranslator translator,
RexCall call, List<Expression> argValueList) {
return EnumUtils.call(
null,
SqlFunctions.class,
methodName,
argValueList);
@@ -57,6 +57,7 @@
import org.apache.ignite.internal.processors.query.calcite.schema.TableDescriptor;
import org.apache.ignite.internal.processors.query.calcite.type.IgniteTypeFactory;
import org.apache.ignite.internal.processors.query.calcite.util.IgniteResource;
import org.jetbrains.annotations.Nullable;

import static org.apache.calcite.util.Static.RESOURCE;
import static org.apache.ignite.internal.processors.query.calcite.Stubs.boolFoo;
@@ -252,10 +253,12 @@ else if (n instanceof SqlDynamicParam) {
}

/** {@inheritDoc} */
@Override public void validateAggregateParams(SqlCall aggCall, SqlNode filter, SqlNodeList orderList, SqlValidatorScope scope) {
@Override public void validateAggregateParams(SqlCall aggCall,
@Nullable SqlNode filter, @Nullable SqlNodeList distinctList,
@Nullable SqlNodeList orderList, SqlValidatorScope scope) {
validateAggregateFunction(aggCall, (SqlAggFunction) aggCall.getOperator());

super.validateAggregateParams(aggCall, filter, orderList, scope);
super.validateAggregateParams(aggCall, filter, null, orderList, scope);
}

/** {@inheritDoc} */
@@ -21,14 +21,17 @@
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.Filter;
import org.apache.calcite.rel.core.RelFactories;
import org.apache.calcite.rel.core.Spool;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.rex.RexNode;
import org.apache.calcite.rex.RexUtil;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteFilter;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteHashIndexSpool;
import org.apache.ignite.internal.processors.query.calcite.rel.IgniteTableSpool;
@@ -38,6 +41,8 @@

import static org.apache.ignite.internal.util.CollectionUtils.nullOrEmpty;

import static org.apache.ignite.internal.processors.query.calcite.util.RexUtils.isBinaryComparison;

/**
* Rule that pushes filter into the spool.
*/
@@ -56,6 +61,7 @@ private FilterSpoolMergeToHashIndexSpoolRule(Config cfg) {
final IgniteTableSpool spool = call.rel(1);

RelOptCluster cluster = spool.getCluster();
RexBuilder builder = RexUtils.builder(cluster);

RelTraitSet trait = spool.getTraitSet();
CorrelationTrait filterCorr = TraitUtils.correlation(filter);
@@ -65,9 +71,20 @@ private FilterSpoolMergeToHashIndexSpoolRule(Config cfg) {

RelNode input = spool.getInput();

RexNode condition0 = RexUtil.expandSearch(builder, null, filter.getCondition());

condition0 = RexUtil.toCnf(builder, condition0);

List<RexNode> conjunctions = RelOptUtil.conjunctions(condition0);

//TODO: https://issues.apache.org/jira/browse/IGNITE-14916
for (RexNode rexNode : conjunctions)
if (!isBinaryComparison(rexNode))
return;

List<RexNode> searchRow = RexUtils.buildHashSearchRow(
cluster,
filter.getCondition(),
condition0,
spool.getRowType()
);

@@ -66,9 +66,10 @@ private LogicalOrToUnionRule(Config config) {

RelNode input = rel.getInput(0);

call.transformTo(rel, ImmutableMap.of(
createUnionAll(cluster, input, operands.get(0), operands.get(1)), rel,
createUnionAll(cluster, input, operands.get(1), operands.get(0)), rel
RelNode rel0 = createUnionAll(cluster, input, operands.get(0), operands.get(1));

call.transformTo(rel0, ImmutableMap.of(
createUnionAll(cluster, input, operands.get(1), operands.get(0)), rel0
));
}

@@ -382,7 +382,7 @@ private static boolean refOnTheRight(RexCall predCall) {
}

/** */
private static boolean isBinaryComparison(RexNode exp) {
public static boolean isBinaryComparison(RexNode exp) {
return TREE_INDEX_COMPARISON.contains(exp.getKind()) &&
(exp instanceof RexCall) &&
((RexCall)exp).getOperands().size() == 2;
@@ -1720,8 +1720,8 @@ public void testMergeJoinIsNotAppliedForNonEquiJoin() throws Exception {

assertNotNull(phys);
assertEquals("" +
"IgniteProject(DEPTNO=[$3], NAME=[$4], ID=[$0], NAME0=[$1], DEPTNO0=[$2])\n" +
" IgniteSort(sort0=[$1], sort1=[$3], dir0=[ASC], dir1=[ASC])\n" +
"IgniteSort(sort0=[$3], sort1=[$0], dir0=[ASC], dir1=[ASC])\n" +
" IgniteProject(DEPTNO=[$3], NAME=[$4], ID=[$0], NAME0=[$1], DEPTNO0=[$2])\n" +
" IgniteNestedLoopJoin(condition=[AND(=($3, $2), >=($1, $4))], joinType=[inner])\n" +
" IgniteIndexScan(table=[[PUBLIC, EMP]], index=[emp_idx])\n" +
" IgniteIndexScan(table=[[PUBLIC, DEPT]], index=[dep_idx])\n",
@@ -73,12 +73,12 @@
<typesafe.version>1.4.1</typesafe.version>
<hamcrest.version>2.2</hamcrest.version>
<scalecube.version>2.6.6</scalecube.version>
<calcite.version>1.26.0</calcite.version>
<janino.version>3.0.11</janino.version>
<avatica.version>1.17.0</avatica.version>
<calcite.version>1.27.0</calcite.version>
<janino.version>3.1.4</janino.version>
<avatica.version>1.18.0</avatica.version>
<jsonpath.version>2.4.0</jsonpath.version>
<reflections.version>0.9.10</reflections.version>
<javassist.version>3.27.0-GA</javassist.version>
<javassist.version>3.28.0-GA</javassist.version>
<esri.geometry.version>2.2.3</esri.geometry.version>
<rocksdb.version>6.20.3</rocksdb.version>
<disruptor.version>3.3.7</disruptor.version>

0 comments on commit c5fb166

Please sign in to comment.