Hive 3.1.2中的UDAF在Spark 3.0.0中不起作用。

huangapple go评论79阅读模式
英文:

Hive 3.1.2 UDAFs not working in Spark 3.0.0

问题

pyspark.sql.utils.AnalysisException: 对 UDF/UDAF/UDTF 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFHistogramNumeric' 没有处理程序: java.lang.NoSuchMethodException: org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo.<init>([Lorg.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;, boolean, boolean); 第4行第29位置

当我尝试在 Spark SQL 中使用 Hive 中的 histogram_numeric 时,出现了上述错误。

我已经包含了相关的 hive-exec jar 包,启用了 hive 支持,我开始怀疑当前是否不支持此功能。

Hive 版本: 3.1.2
Spark 版本: 3.0.0

如果有人能提供一个简单的代码片段,在 Spark 3.0.0 中注册 Hive UDAF 并能正常工作,那将非常有用。

英文:

pyspark.sql.utils.AnalysisException: No handler for UDF/UDAF/UDTF &#39;org.apache.hadoop.hive.ql.udf.generic.GenericUDAFHistogramNumeric&#39;: java.lang.NoSuchMethodException: org.apache.hadoop.hive.ql.udf.generic.SimpleGenericUDAFParameterInfo.&lt;init&gt;([Lorg.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;, boolean, boolean); line 4 pos 29

I get the above error when I try to use histogram_numeric from Hive in Spark SQL.

I've included the relevant hive-exec jar, enabled hive support and I'm starting to wonder if this isn't supported at the moment.

Hive version: 3.1.2
Spark version: 3.0.0

If someone has a simple snippet which works for them when registering Hive UDAFs in Spark 3.0.0 that would be super useful too

答案1

得分: 1

我尝试通过hiveCtx.udf.registerJavaUDAF注册Hive UADF,但没有成功。

hiveCtx.udf.registerJavaUDAF("histogram_numeric", "org.apache.hadoop.hive.ql.udf.generic.GenericUDAFHistogramNumeric")

实现"histogram_numeric"的Hive类是存在的,但不符合Spark的Java UDAF接口。

但我发现使用DataFrame的selectExpr代码是有效的。我不知道原因。

users_spark_df.selectExpr('histogram_numeric(age, 2)')

链接:https://stackoverflow.com/questions/36043256/making-histogram-with-spark-dataframe-column

英文:

I tried to register hive uadf via hiveCtx.udf.registerJavaUDAF, but no luck.

hiveCtx.udf.registerJavaUDAF(&quot;histogram_numeric&quot;, &quot;org.apache.hadoop.hive.ql.udf.generic.GenericUDAFHistogramNumeric&quot;)

The hive class which implements "histogram_numeric" was there, but it doesn't conform to spark's JavaUADF interface.

But I found the code with dataframe's selectExpr works. I don't know why.

users_spark_df.selectExpr(&#39;histogram_numeric(age, 2)&#39;)

https://stackoverflow.com/questions/36043256/making-histogram-with-spark-dataframe-column

huangapple
  • 本文由 发表于 2020年9月16日 22:30:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/63922269.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定