use of org.apache.flink.table.functions.TableAggregateFunctionDefinition in project flink by apache.
the class SqlAggFunctionVisitor method createSqlAggFunction.
private SqlAggFunction createSqlAggFunction(CallExpression call) {
final FunctionDefinition definition = call.getFunctionDefinition();
// legacy
if (definition instanceof AggregateFunctionDefinition) {
return createLegacySqlAggregateFunction(call.getFunctionIdentifier().orElse(null), (AggregateFunctionDefinition) definition);
} else if (definition instanceof TableAggregateFunctionDefinition) {
return createLegacySqlTableAggregateFunction(call.getFunctionIdentifier().orElse(null), (TableAggregateFunctionDefinition) definition);
}
// new stack
final DataTypeFactory dataTypeFactory = ShortcutUtils.unwrapContext(relBuilder).getCatalogManager().getDataTypeFactory();
final TypeInference typeInference = definition.getTypeInference(dataTypeFactory);
return BridgingSqlAggFunction.of(dataTypeFactory, ShortcutUtils.unwrapTypeFactory(relBuilder), SqlKind.OTHER_FUNCTION, ContextResolvedFunction.fromCallExpression(call), typeInference);
}
use of org.apache.flink.table.functions.TableAggregateFunctionDefinition in project flink by apache.
the class FunctionCatalog method registerTempSystemAggregateFunction.
/**
* @deprecated Use {@link #registerTemporarySystemFunction(String, FunctionDefinition, boolean)}
* instead.
*/
@Deprecated
public <T, ACC> void registerTempSystemAggregateFunction(String name, ImperativeAggregateFunction<T, ACC> function, TypeInformation<T> resultType, TypeInformation<ACC> accType) {
UserDefinedFunctionHelper.prepareInstance(config, function);
final FunctionDefinition definition;
if (function instanceof AggregateFunction) {
definition = new AggregateFunctionDefinition(name, (AggregateFunction<?, ?>) function, resultType, accType);
} else if (function instanceof TableAggregateFunction) {
definition = new TableAggregateFunctionDefinition(name, (TableAggregateFunction<?, ?>) function, resultType, accType);
} else {
throw new TableException("Unknown function class: " + function.getClass());
}
registerTempSystemFunction(name, definition);
}
use of org.apache.flink.table.functions.TableAggregateFunctionDefinition in project flink by apache.
the class RexNodeJsonSerializer method serializeBridgingSqlFunction.
private static void serializeBridgingSqlFunction(String summaryName, ContextResolvedFunction resolvedFunction, JsonGenerator gen, SerializerProvider serializerProvider, boolean serializeCatalogObjects) throws IOException {
final FunctionDefinition definition = resolvedFunction.getDefinition();
if (definition instanceof ScalarFunctionDefinition || definition instanceof TableFunctionDefinition || definition instanceof TableAggregateFunctionDefinition || definition instanceof AggregateFunctionDefinition) {
throw legacyException(summaryName);
}
if (definition instanceof BuiltInFunctionDefinition) {
final BuiltInFunctionDefinition builtInFunction = (BuiltInFunctionDefinition) definition;
gen.writeStringField(FIELD_NAME_INTERNAL_NAME, builtInFunction.getQualifiedName());
} else if (resolvedFunction.isAnonymous()) {
serializeInlineFunction(summaryName, definition, gen);
} else if (resolvedFunction.isTemporary()) {
serializeTemporaryFunction(resolvedFunction, gen, serializerProvider);
} else {
assert resolvedFunction.isPermanent();
serializePermanentFunction(resolvedFunction, gen, serializerProvider, serializeCatalogObjects);
}
}
Aggregations