【问题标题】:How to implement Apache Beam UDF for Calcite SQL?如何为 Calcite SQL 实现 Apache Beam UDF?
【发布时间】:2020-12-16 00:32:52
【问题描述】:

我正在尝试在我的 Apache Beam 管道中实现一个简单的 BitwiseAnd 作为 SQL 的 UDF。这是简单的代码sn-p

public static class BitwiseAnd implements BeamSqlUdf {
    public static Integer eval(Integer input, Integer bit){
        return input & bit;
    }
}

但是,我收到以下错误:

No match found for function signature BitwiseAnd(<NUMERIC>, <NUMERIC>)

我也尝试在方法签名中使用 Long 并得到以下错误

没有找到适用于实际参数“java.lang.Integer, long”的构造函数/方法;候选人是:“public static java.lang.Long SqlTest$BitwiseAnd.eval(java.lang.Long, java.lang.Long)”

任何帮助将不胜感激。

【问题讨论】:

    标签: java apache-beam


    【解决方案1】:

    看起来您正在使用此 UDF 的上下文期望签名是

    public static Integer eval(Integer input, Long bit) { ... }
    

    您也可以在 UDF 之前转换一侧以匹配另一侧的类型。

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 2021-05-12
      • 2019-10-05
      • 2020-02-04
      • 2021-08-07
      • 2020-06-01
      • 1970-01-01
      • 2018-07-05
      • 1970-01-01
      相关资源
      最近更新 更多