private AggregateCall createAggregateCallWithBinding( RelDataTypeFactory typeFactory, SqlAggFunction aggFunction, RelDataType operandType, Aggregate oldAggRel, AggregateCall oldCall, int argOrdinal) { final Aggregate.AggCallBinding binding = new Aggregate.AggCallBinding(typeFactory, aggFunction, ImmutableList.of(operandType), oldAggRel.getGroupCount(), oldCall.filterArg >= 0); return AggregateCall.create(aggFunction, oldCall.isDistinct(), oldCall.isApproximate(), ImmutableIntList.of(argOrdinal), oldCall.filterArg, aggFunction.inferReturnType(binding), null); }
/** * Returns whether the inferred type of an {@link AggregateCall} matches the * type it was given when it was created. * * @param aggCall Aggregate call * @param litmus What to do if an error is detected (types do not match) * @return Whether the inferred and declared types match */ private boolean typeMatchesInferred( final AggregateCall aggCall, final Litmus litmus) { SqlAggFunction aggFunction = aggCall.getAggregation(); AggCallBinding callBinding = aggCall.createBinding(this); RelDataType type = aggFunction.inferReturnType(callBinding); RelDataType expectedType = aggCall.type; return RelOptUtil.eq("aggCall type", expectedType, "inferred type", type, litmus); }
/** * Returns whether the inferred type of an {@link AggregateCall} matches the * type it was given when it was created. * * @param aggCall Aggregate call * @param litmus What to do if an error is detected (types do not match) * @return Whether the inferred and declared types match */ private boolean typeMatchesInferred( final AggregateCall aggCall, final Litmus litmus) { SqlAggFunction aggFunction = aggCall.getAggregation(); AggCallBinding callBinding = aggCall.createBinding(this); RelDataType type = aggFunction.inferReturnType(callBinding); RelDataType expectedType = aggCall.type; return RelOptUtil.eq("aggCall type", expectedType, "inferred type", type, litmus); }
private AggregateCall createAggregateCallWithBinding( RelDataTypeFactory typeFactory, SqlAggFunction aggFunction, RelDataType operandType, Aggregate oldAggRel, AggregateCall oldCall, int argOrdinal, int filter) { final Aggregate.AggCallBinding binding = new Aggregate.AggCallBinding(typeFactory, aggFunction, ImmutableList.of(operandType), oldAggRel.getGroupCount(), filter >= 0); return AggregateCall.create(aggFunction, oldCall.isDistinct(), oldCall.isApproximate(), ImmutableIntList.of(argOrdinal), filter, aggFunction.inferReturnType(binding), null); }
operator.inferReturnType(getTypeFactory(), types), operator, expressions,
private AggregateCall createAggregateCallWithBinding( RelDataTypeFactory typeFactory, SqlAggFunction aggFunction, RelDataType operandType, Aggregate oldAggRel, AggregateCall oldCall, int argOrdinal, int filter) { final Aggregate.AggCallBinding binding = new Aggregate.AggCallBinding(typeFactory, aggFunction, ImmutableList.of(operandType), oldAggRel.getGroupCount(), filter >= 0); return AggregateCall.create(aggFunction, oldCall.isDistinct(), oldCall.isApproximate(), ImmutableIntList.of(argOrdinal), filter, oldCall.collation, aggFunction.inferReturnType(binding), null); }
/** Creates an AggregateCall, inferring its type if {@code type} is null. */ public static AggregateCall create(SqlAggFunction aggFunction, boolean distinct, boolean approximate, List<Integer> argList, int filterArg, RelCollation collation, int groupCount, RelNode input, RelDataType type, String name) { if (type == null) { final RelDataTypeFactory typeFactory = input.getCluster().getTypeFactory(); final List<RelDataType> types = SqlTypeUtil.projectTypes(input.getRowType(), argList); final Aggregate.AggCallBinding callBinding = new Aggregate.AggCallBinding(typeFactory, aggFunction, types, groupCount, filterArg >= 0); type = aggFunction.inferReturnType(callBinding); } return create(aggFunction, distinct, approximate, argList, filterArg, collation, type, name); }
/** Creates an AggregateCall, inferring its type if {@code type} is null. */ public static AggregateCall create(SqlAggFunction aggFunction, boolean distinct, boolean approximate, List<Integer> argList, int filterArg, int groupCount, RelNode input, RelDataType type, String name) { if (type == null) { final RelDataTypeFactory typeFactory = input.getCluster().getTypeFactory(); final List<RelDataType> types = SqlTypeUtil.projectTypes(input.getRowType(), argList); final Aggregate.AggCallBinding callBinding = new Aggregate.AggCallBinding(typeFactory, aggFunction, types, groupCount, filterArg >= 0); type = aggFunction.inferReturnType(callBinding); } return create(aggFunction, distinct, approximate, argList, filterArg, type, name); }
public RexNode convertAggregateFunction( SqlRexContext cx, SqlAggFunction fun, SqlCall call) { final List<SqlNode> operands = call.getOperandList(); final List<RexNode> exprs; if (call.isCountStar()) { exprs = ImmutableList.of(); } else { exprs = convertExpressionList(cx, operands, SqlOperandTypeChecker.Consistency.NONE); } RelDataType returnType = cx.getValidator().getValidatedNodeTypeIfKnown(call); final int groupCount = cx.getGroupCount(); if (returnType == null) { RexCallBinding binding = new RexCallBinding(cx.getTypeFactory(), fun, exprs, ImmutableList.of()) { @Override public int getGroupCount() { return groupCount; } }; returnType = fun.inferReturnType(binding); } return cx.getRexBuilder().makeCall(returnType, fun, exprs); }
public RexNode convertAggregateFunction( SqlRexContext cx, SqlAggFunction fun, SqlCall call) { final List<SqlNode> operands = call.getOperandList(); final List<RexNode> exprs; if (call.isCountStar()) { exprs = ImmutableList.of(); } else { exprs = convertExpressionList(cx, operands, SqlOperandTypeChecker.Consistency.NONE); } RelDataType returnType = cx.getValidator().getValidatedNodeTypeIfKnown(call); final int groupCount = cx.getGroupCount(); if (returnType == null) { RexCallBinding binding = new RexCallBinding(cx.getTypeFactory(), fun, exprs, ImmutableList.of()) { @Override public int getGroupCount() { return groupCount; } }; returnType = fun.inferReturnType(binding); } return cx.getRexBuilder().makeCall(returnType, fun, exprs); }
rexBuilder.makeOver( SqlStdOperatorTable.HISTOGRAM_AGG .inferReturnType(bind), SqlStdOperatorTable.HISTOGRAM_AGG, exprs,
rexBuilder.makeOver( SqlStdOperatorTable.HISTOGRAM_AGG .inferReturnType(bind), SqlStdOperatorTable.HISTOGRAM_AGG, exprs,
rexBuilder.makeOver( SqlStdOperatorTable.HISTOGRAM_AGG .inferReturnType(bind), SqlStdOperatorTable.HISTOGRAM_AGG, exprs,
rexBuilder.makeOver( SqlStdOperatorTable.HISTOGRAM_AGG .inferReturnType(bind), SqlStdOperatorTable.HISTOGRAM_AGG, exprs,