Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Calcite to 1.37 #2949

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exec/java-exec/src/main/codegen/templates/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ void LimitClause(Span s, SqlNode[] offsetFetch) :
<COMMA> offsetFetch[1] = UnsignedNumericLiteralOrParam() {
if (!this.conformance.isLimitStartCountAllowed()) {
throw SqlUtil.newContextException(s.end(this),
RESOURCE.limitStartCountNotAllowed());
RESOURCE.limitStartCountOrAllNotAllowed(offsetFetch[1].toString()));
}
}
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,16 @@ public DrillWindowRelBase(
List<Group> windows) {
super(cluster, traits, child, constants, DrillRelOptUtil.uniqifyFieldName(rowType, cluster.getTypeFactory()), windows);
}

@Override
public Window copy(List<RexLiteral> constants) {
return new DrillWindowRelBase(
super.getCluster(),
super.getTraitSet(),
super.getInput(),
constants,
super.getRowType(),
super.groups
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,11 @@ private static AggregateCall getAggCall(AggregateCall oldCall,
return AggregateCall.create(aggFunction,
oldCall.isDistinct(),
oldCall.isApproximate(),
oldCall.ignoreNulls(),
oldCall.getArgList(),
oldCall.filterArg,
oldCall.distinctKeys,
oldCall.getCollation(),
oldCall.collation,
sumType,
null);
oldCall.name);
}

private RexNode reduceSum(
Expand Down Expand Up @@ -541,6 +539,7 @@ private RexNode reduceStddev(
oldCall.isDistinct(),
oldCall.isApproximate(),
oldCall.ignoreNulls(),
ImmutableList.of(),
ImmutableIntList.of(argSquaredOrdinal),
oldCall.filterArg,
oldCall.distinctKeys,
Expand All @@ -562,6 +561,7 @@ private RexNode reduceStddev(
oldCall.isDistinct(),
oldCall.isApproximate(),
oldCall.ignoreNulls(),
ImmutableList.of(),
ImmutableIntList.of(argOrdinal),
oldCall.filterArg,
oldCall.distinctKeys,
Expand Down Expand Up @@ -739,6 +739,7 @@ public void onMatch(RelOptRuleCall call) {
oldAggregateCall.isDistinct(),
oldAggregateCall.isApproximate(),
oldAggregateCall.ignoreNulls(),
ImmutableList.of(),
oldAggregateCall.getArgList(),
oldAggregateCall.filterArg,
oldAggregateCall.distinctKeys,
Expand Down Expand Up @@ -837,7 +838,7 @@ private static boolean isConversionToSumZeroNeeded(SqlOperator sqlOperator, RelD
&& !type.isNullable()) {
// If SUM(x) is not nullable, the validator must have determined that
// nulls are impossible (because the group is never empty and x is never
// null). Therefore we translate to SUM0(x).
// null). Therefore, we translate to SUM0(x).
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,32 @@
*/
package org.apache.drill.exec.planner.physical;

import org.apache.drill.common.expression.IfExpression;
import org.apache.drill.common.expression.NullExpression;
import com.google.common.collect.Lists;
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.InvalidRelException;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.AggregateCall;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlAggFunction;
import org.apache.calcite.sql.SqlFunctionCategory;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.util.BitSets;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.Optionality;
import org.apache.drill.common.expression.ExpressionPosition;
import org.apache.drill.common.expression.FieldReference;
import org.apache.drill.common.expression.FunctionCall;
import org.apache.drill.common.expression.IfExpression;
import org.apache.drill.common.expression.LogicalExpression;
import org.apache.drill.common.expression.NullExpression;
import org.apache.drill.common.expression.ValueExpressions;
import org.apache.drill.common.logical.data.NamedExpression;
import org.apache.drill.exec.planner.common.DrillAggregateRelBase;
import org.apache.drill.exec.planner.physical.visitor.PrelVisitor;
import org.apache.calcite.rel.core.AggregateCall;
import org.apache.calcite.rel.InvalidRelException;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.sql.SqlAggFunction;
import org.apache.calcite.sql.SqlFunctionCategory;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.util.Optionality;

import java.util.Collections;
import java.util.Iterator;
Expand Down Expand Up @@ -182,7 +181,6 @@ protected void createKeysAndExprs() {
Collections.singletonList(aggExprOrdinal),
aggCall.e.filterArg,
null,
RelCollations.EMPTY,
aggCall.e.getType(),
aggCall.e.getName());

Expand All @@ -197,7 +195,6 @@ protected void createKeysAndExprs() {
Collections.singletonList(aggExprOrdinal),
aggCall.e.filterArg,
null,
RelCollations.EMPTY,
aggCall.e.getType(),
aggCall.e.getName());

Expand Down Expand Up @@ -273,7 +270,6 @@ public Prel prepareForLateralUnnestPipeline(List<RelNode> children) {
arglist,
aggCall.filterArg,
null,
RelCollations.EMPTY,
aggCall.type,
aggCall.name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
*/
package org.apache.drill.exec.planner.sql;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableMap;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexNode;
Expand All @@ -35,15 +28,22 @@
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlNumericLiteral;
import org.apache.calcite.sql.SqlOperator;
import org.apache.calcite.sql.fun.SqlRandFunction;
import org.apache.calcite.sql.fun.SqlRandIntegerFunction;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql2rel.SqlRexConvertlet;
import org.apache.calcite.sql2rel.SqlRexConvertletTable;
import org.apache.calcite.sql2rel.StandardConvertletTable;
import org.apache.drill.exec.planner.sql.parser.DrillCalciteWrapperUtility;
import com.google.common.collect.ImmutableMap;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* Convertlet table which allows to plug-in custom rex conversion of calls to
Expand Down Expand Up @@ -159,7 +159,7 @@ private static SqlRexConvertlet randConvertlet() {
List<RexNode> operands = call.getOperandList().stream()
.map(cx::convertExpression)
.collect(Collectors.toList());
return cx.getRexBuilder().makeCall(new SqlRandFunction() {
return cx.getRexBuilder().makeCall(new SqlRandIntegerFunction() {
@Override
public boolean isDeterministic() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public RelRoot toRel(final SqlNode validatedNode) {

RelNode relNode = rel.rel;
List<RexNode> expressions = rel.fields.stream()
.map(f -> builder.makeInputRef(relNode, f.left))
.map(f -> builder.makeInputRef(relNode, f.getKey()))
.collect(Collectors.toList());

RelNode project = LogicalProject.create(rel.rel, Collections.emptyList(), expressions, rel.validatedRowType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.apache.calcite.rex.RexFieldAccess;
import org.apache.calcite.rex.RexFieldCollation;
import org.apache.calcite.rex.RexInputRef;
import org.apache.calcite.rex.RexLambda;
import org.apache.calcite.rex.RexLambdaRef;
import org.apache.calcite.rex.RexLiteral;
import org.apache.calcite.rex.RexLocalRef;
import org.apache.calcite.rex.RexNode;
Expand Down Expand Up @@ -132,4 +134,14 @@ public Boolean visitTableInputRef(RexTableInputRef fieldRef) {
public Boolean visitPatternFieldRef(RexPatternFieldRef fieldRef) {
return false;
}

@Override
public Boolean visitLambda(RexLambda lambda) {
return false;
}

@Override
public Boolean visitLambdaRef(RexLambdaRef lambdaRef) {
return false;
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<avro.version>1.11.3</avro.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<calcite.groupId>org.apache.calcite</calcite.groupId>
<calcite.version>1.34.0</calcite.version>
<calcite.version>1.37.0</calcite.version>
<codemodel.version>2.6</codemodel.version>
<commons.beanutils.version>1.9.4</commons.beanutils.version>
<commons.cli.version>1.4</commons.cli.version>
Expand Down
Loading