/** * 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); }
TypeInferenceUtils.getDrillSqlReturnTypeInference(SqlKind.SUM.name(), ImmutableList.of()) .inferReturnType(oldCall.createBinding(oldAggRel)); sumType = typeFactory.createTypeWithNullability(sumType, true); final AggregateCall sumArgSquaredAggCall =
TypeInferenceUtils.getDrillSqlReturnTypeInference(SqlKind.SUM.name(), ImmutableList.of()) .inferReturnType(oldCall.createBinding(oldAggRel)); sumType = typeFactory.createTypeWithNullability(