本文整理汇总了Java中org.apache.calcite.rel.core.AggregateCall.getType方法的典型用法代码示例。如果您正苦于以下问题:Java AggregateCall.getType方法的具体用法?Java AggregateCall.getType怎么用?Java AggregateCall.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.core.AggregateCall
的用法示例。
在下文中一共展示了AggregateCall.getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteAggregateCall
import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private AggregateCall rewriteAggregateCall(AggregateCall aggCall, FunctionDesc func) {
// rebuild function
String callName = getSqlFuncName(aggCall);
RelDataType fieldType = aggCall.getType();
SqlAggFunction newAgg = aggCall.getAggregation();
Map<String, Class<?>> udafMap = func.getMeasureType().getRewriteCalciteAggrFunctions();
if (func.isCount()) {
newAgg = SqlStdOperatorTable.SUM0;
} else if (udafMap != null && udafMap.containsKey(callName)) {
newAgg = createCustomAggFunction(callName, fieldType, udafMap.get(callName));
}
// rebuild parameters
List<Integer> newArgList = Lists.newArrayList(aggCall.getArgList());
if (udafMap != null && udafMap.containsKey(callName)) {
newArgList = truncArgList(newArgList, udafMap.get(callName));
}
if (func.needRewriteField()) {
RelDataTypeField field = getInput().getRowType().getField(func.getRewriteFieldName(), true, false);
if (newArgList.isEmpty()) {
newArgList.add(field.getIndex());
} else {
// TODO: only the first column got overwritten
newArgList.set(0, field.getIndex());
}
}
// rebuild aggregate call
AggregateCall newAggCall = new AggregateCall(newAgg, false, newArgList, fieldType, callName);
return newAggCall;
}
示例2: transformAggCalls
import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
private List<AggregateCall> transformAggCalls(RelNode input, int groupCount,
List<AggregateCall> origCalls) {
final List<AggregateCall> newCalls = Lists.newArrayList();
for (Ord<AggregateCall> ord : Ord.zip(origCalls)) {
final AggregateCall origCall = ord.e;
if (origCall.isDistinct()
|| !SUPPORTED_AGGREGATES.containsKey(origCall.getAggregation()
.getClass())) {
return null;
}
final SqlAggFunction aggFun;
final RelDataType aggType;
if (origCall.getAggregation() == SqlStdOperatorTable.COUNT) {
aggFun = SqlStdOperatorTable.SUM0;
// count(any) is always not null, however nullability of sum might
// depend on the number of columns in GROUP BY.
// Here we use SUM0 since we are sure we will not face nullable
// inputs nor we'll face empty set.
aggType = null;
} else {
aggFun = origCall.getAggregation();
aggType = origCall.getType();
}
AggregateCall newCall =
AggregateCall.create(aggFun, origCall.isDistinct(),
origCall.isApproximate(),
ImmutableList.of(groupCount + ord.i), -1, groupCount, input,
aggType, origCall.getName());
newCalls.add(newCall);
}
return newCalls;
}
示例3: onMatch
import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final DrillAggregateRel oldAggRel = (DrillAggregateRel) call.rels[0];
final Map<AggregateCall, RexNode> aggCallMapping = Maps.newHashMap();
final List<AggregateCall> newAggregateCalls = Lists.newArrayList();
for (AggregateCall oldAggregateCall : oldAggRel.getAggCallList()) {
if(isConversionToSumZeroNeeded(oldAggregateCall.getAggregation(), oldAggregateCall.getType())) {
final RelDataType argType = oldAggregateCall.getType();
final RelDataType sumType = oldAggRel.getCluster().getTypeFactory()
.createTypeWithNullability(argType, argType.isNullable());
final SqlAggFunction sumZeroAgg = new DrillCalciteSqlAggFunctionWrapper(
new SqlSumEmptyIsZeroAggFunction(), sumType);
AggregateCall sumZeroCall =
AggregateCall.create(
sumZeroAgg,
oldAggregateCall.isDistinct(),
oldAggregateCall.getArgList(),
-1,
sumType,
oldAggregateCall.getName());
oldAggRel.getCluster().getRexBuilder()
.addAggCall(sumZeroCall,
oldAggRel.getGroupCount(),
oldAggRel.indicator,
newAggregateCalls,
aggCallMapping,
ImmutableList.of(argType));
} else {
newAggregateCalls.add(oldAggregateCall);
}
}
try {
call.transformTo(new DrillAggregateRel(
oldAggRel.getCluster(),
oldAggRel.getTraitSet(),
oldAggRel.getInput(),
oldAggRel.indicator,
oldAggRel.getGroupSet(),
oldAggRel.getGroupSets(),
newAggregateCalls));
} catch (InvalidRelException e) {
tracer.warning(e.toString());
}
}