use of org.apache.calcite.sql.validate.SqlUserDefinedAggFunction in project storm by apache.
the class RelNodeCompiler method aggregate.
private void aggregate(AggregateCall call) {
SqlAggFunction aggFunction = call.getAggregation();
String aggregationName = call.getAggregation().getName();
Type ty = typeFactory.getJavaClass(call.getType());
if (call.getArgList().size() != 1) {
if (aggregationName.equals("COUNT")) {
if (call.getArgList().size() != 0) {
throw new UnsupportedOperationException("Count with nullable fields");
}
}
}
if (aggFunction instanceof SqlUserDefinedAggFunction) {
AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
doAggregate((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, call.getArgList());
} else {
List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
if (typeClasses == null) {
throw new UnsupportedOperationException(aggregationName + " Not implemented");
}
doAggregate(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, call.getArgList());
}
}
use of org.apache.calcite.sql.validate.SqlUserDefinedAggFunction in project calcite by apache.
the class CalciteCatalogReader method operatorTable.
/**
* Creates an operator table that contains functions in the given class.
*
* @see ModelHandler#addFunctions
*/
public static SqlOperatorTable operatorTable(String className) {
// Dummy schema to collect the functions
final CalciteSchema schema = CalciteSchema.createRootSchema(false, false);
ModelHandler.addFunctions(schema.plus(), null, ImmutableList.<String>of(), className, "*", true);
// The following is technical debt; see [CALCITE-2082] Remove
// RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor
final SqlTypeFactoryImpl typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
final ListSqlOperatorTable table = new ListSqlOperatorTable();
for (String name : schema.getFunctionNames()) {
for (Function function : schema.getFunctions(name, true)) {
final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO);
table.add(toOp(typeFactory, id, function));
}
}
return table;
}
use of org.apache.calcite.sql.validate.SqlUserDefinedAggFunction in project storm by apache.
the class RelNodeCompiler method aggregateResult.
private String aggregateResult(AggregateCall call, PrintWriter pw) {
SqlAggFunction aggFunction = call.getAggregation();
String aggregationName = call.getAggregation().getName();
Type ty = typeFactory.getJavaClass(call.getType());
String result;
if (aggFunction instanceof SqlUserDefinedAggFunction) {
AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
} else {
List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
if (typeClasses == null) {
throw new UnsupportedOperationException(aggregationName + " Not implemented");
}
result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, pw);
}
return result;
}
use of org.apache.calcite.sql.validate.SqlUserDefinedAggFunction in project streamline by hortonworks.
the class RelNodeCompiler method aggregate.
private void aggregate(AggregateCall call) {
SqlAggFunction aggFunction = call.getAggregation();
String aggregationName = call.getAggregation().getName();
Type ty = typeFactory.getJavaClass(call.getType());
if (call.getArgList().size() != 1) {
if (aggregationName.equals("COUNT")) {
if (call.getArgList().size() != 0) {
throw new UnsupportedOperationException("Count with nullable fields");
}
}
}
if (aggFunction instanceof SqlUserDefinedAggFunction) {
AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
doAggregate((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, call.getArgList());
} else {
List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
if (typeClasses == null) {
throw new UnsupportedOperationException(aggregationName + " Not implemented");
}
doAggregate(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, call.getArgList());
}
}
use of org.apache.calcite.sql.validate.SqlUserDefinedAggFunction in project streamline by hortonworks.
the class RelNodeCompiler method aggregateResult.
private String aggregateResult(AggregateCall call, PrintWriter pw) {
SqlAggFunction aggFunction = call.getAggregation();
String aggregationName = call.getAggregation().getName();
Type ty = typeFactory.getJavaClass(call.getType());
String result;
if (aggFunction instanceof SqlUserDefinedAggFunction) {
AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
} else {
List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
if (typeClasses == null) {
throw new UnsupportedOperationException(aggregationName + " Not implemented");
}
result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)), reserveAggVarName(call), ty, pw);
}
return result;
}
Aggregations