gpt4 book ai didi

hadoop - 配置单元 : reflect function

转载 作者:可可西里 更新时间:2023-11-01 16:01:41 25 4
gpt4 key购买 nike

我正在尝试使用 Reflect具有此签名的 Hive 函数:

reflect(class, method[, arg1[, arg2..]])

我想检查值 hello world ! 的列 c 是否包含 world,所以我写道:

with a as
(select "hello world !" as c)
select reflect("java.lang.String",c ,"contains", "world") from a

但它没有用,因为它不尊重签名,所以我尝试了这个

with a as
(select "hello world !" as c)
select reflect(reflect("java.lang.Object","toString",c) ,"contains", "world") from a

它也没有用!我想知道如何在给定列上应用 reflect 函数?

最佳答案

reflect2 会有所帮助。参见 https://issues.apache.org/jira/browse/HIVE-20007

select reflect2("stackoverflow","length");  
+------+--+
| _c0 |
+------+--+
| 13 |
+------+--+

但 hashCode() 将不起作用。参见 https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFReflect2.java#L86

select reflect2("stackoverflow","hashCode");
Error: Error while compiling statement: FAILED: SemanticException [Error 10016]: Line 1:32 Argument type mismatch '"hashCode"': Use hash() UDF instead of this.

关于hadoop - 配置单元 : reflect function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38309083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com