如何从udf和广播变量访问广播变量是在调用此udf的另一个类中定义的。
/* this udf is in different file */
package com.abc
public class JavaClass{
public static UserDefinedFunction getvalue = udf((String param) -> {
return "String value";
}, DataTypes.StringType);
}
**/* below code is in different file */**
package com.xyz;
import com.abc.JavaClass;
public class AnotherClassToCallUDF{
pubic static void main(String args[]) {
Dataset<Row> abc = .......;
abc.withColoumn("new-col",JavaClass.getvalue.apply("passing some value"));
}
}
**/* in the above code , how to pass broadcast variable while calling udf...since udf accepts only col typ`enter code here`e and lit type ..it does not accept anything else..then how to access broadcast variable which is defined in main class and accessing in another class..
* /**
1条答案
按热度按时间2eafrhcq1#
试试这个-
1. 创建自定义项
2. 使用自定义项传递广播并使用它
3. 不向functionregistry注册udf