twalthr commented on a change in pull request #8661: [FLINK-12711][table]
Separate function implementation and definition
URL: https://github.com/apache/flink/pull/8661#discussion_r294738754
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/UserDefinedFunction.java
##########
@@ -24,11 +24,18 @@
import java.io.Serializable;
/**
- * Base class for all user-defined functions such as scalar functions, table
functions,
- * or aggregation functions.
+ * Base class for all user-defined functions.
+ *
+ * <p>User-defined functions combine the logical definition of a function for
validation and planning
+ * (see {@link UserDefinedFunctionDefinition}) and contain a corresponding
runtime implementation.
+ *
+ * @see ScalarFunction
+ * @see TableFunction
+ * @see AggregateFunction
+ * @see TableAggregateFunction
*/
@PublicEvolving
-public abstract class UserDefinedFunction implements Serializable {
+public abstract class UserDefinedFunction implements
UserDefinedFunctionDefinition, Serializable {
Review comment:
I removed `UserDefinedFunctionDefinition` for now. It is difficult to
clearly separate definition and implementation for UDFs. Let's consider
`UserDefinedFunction` as a special kind of `FunctionDefinition`. In the future
we could think about a design like the following:
```
InvokableFunction
- open()
- close()
UserDefinedFunction extends InvokableFunction
FunctionDefinition
- getKind()
- getRequirements()
- isDeterministic()
- getTypeInference()
- createInvokableFunction(): Optional<InvokableFunction>
InvokableScalarFunction extends InvokableFunction
InvokableTableFunction extends InvokableFunction
- setCollector()
- collect()
InvokableAsyncTableFunction extends InvokableFunction
InvokableAggregateFunction extends InvokableFunction
- getValue()
- createAccumulator()
InvokableTableAggregateFunction extends InvokableFunction
- createAccumulator()
- createAccumulator()
ScalarFunction extends UserDefinedFunction implements
InvokableScalarFunction, FunctionDefinition
TableFunction extends UserDefinedFunction implements InvokableTableFunction,
FunctionDefinition
AggregateFunction extends UserDefinedFunction implements
InvokableAggregateFunction, FunctionDefinition
TableAggregateFunction extends UserDefinedFunction implements
InvokableTableAggregateFunction, FunctionDefinition
```
But this requires major changes in how UDFs are shipped to the cluster and
instantiated.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services