1

我正在尝试按照此处的步骤创建基本的 Flink Aggregate UDF。我已经添加了依赖项()并实现了

public class MyAggregate extends AggregateFunction<Long, TestAgg> {..}

我已经实现了强制方法以及其他一些方法:accumulate, merge, etc. 所有这些构建都没有错误。现在根据文档,我应该可以将其注册为

    StreamExecutionEnvironment sEnv = StreamExecutionEnvironment.getExecutionEnvironment();
    StreamTableEnvironment sTableEnv = StreamTableEnvironment.getTableEnvironment(sEnv);
    sTableEnv.registerFunction("MyMin", new MyAggregate());

但是,registerFucntion似乎ScalarFunction只需要一个作为输入。我收到不兼容的类型错误:The method registerFunction(String, ScalarFunction) in the type TableEnvironment is not applicable for the arguments (String, MyAggregate)

任何帮助都会很棒。

4

1 回答 1

2

您需要StreamTableEnvironment为您选择的语言导入您的情况org.apache.flink.table.api.java.StreamTableEnvironment

org.apache.flink.table.api.StreamTableEnvironment是 Java 和 Scala 变体的通用抽象类StreamTableEnvironment。我们注意到 API 的这一部分让用户感到困惑,我们将在未来对其进行改进。

于 2018-03-15T21:32:39.430 回答