我试图使用具有此签名的Hive Reflect函数:
reflect(class, method[, arg1[, arg2..]])
我想知道价值c
的列hello world !
是否包含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
函数?
答案 0 :(得分:0)
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.