简体   繁体   English

如何为方解石 SQL 实施 Apache Beam UDF?

[英]How to implement Apache Beam UDF for Calcite SQL?

I'm trying to implement a simple BitwiseAnd as a UDF for SQL in my Apache Beam pipeline.我正在尝试在我的 Apache Beam 管道中实现一个简单的 BitwiseAnd 作为 SQL 的 UDF。 Here is the simple code snippet这是简单的代码片段

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

However, I get the following error:但是,我收到以下错误:

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

I've also tried with with Long in the method signature and get the following error我也尝试在方法签名中使用Long并得到以下错误

No applicable constructor/method found for actual parameters "java.lang.Integer, long";未找到适用于实际参数“java.lang.Integer, long”的构造函数/方法; candidates are: "public static java.lang.Long SqlTest$BitwiseAnd.eval(java.lang.Long, java.lang.Long)"候选人是:“公共 static java.lang.Long SqlTest$BitwiseAnd.eval(java.lang.Long, javalang)”。

Any help would be appreciated.任何帮助,将不胜感激。

It looks like the context you are using this UDF in is expecting the signature to be看起来您在其中使用此 UDF 的上下文期望签名为

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

You could also cast one side to match the type of the other before the UDF as well.您也可以在 UDF 之前投射一侧以匹配另一侧的类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM