You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Ang Chen (JIRA)" <ji...@apache.org> on 2019/02/16 19:23:00 UTC
[jira] [Created] (HIVE-21282) Add reflect_complicated() UDF for
reflective invocation of Java methods to generate non-primitive result
Ang Chen created HIVE-21282:
-------------------------------
Summary: Add reflect_complicated() UDF for reflective invocation of Java methods to generate non-primitive result
Key: HIVE-21282
URL: https://issues.apache.org/jira/browse/HIVE-21282
Project: Hive
Issue Type: Improvement
Reporter: Ang Chen
Assignee: Ang Chen
The reflect/java_method only supports primitive return result. Would be great if we could add another UDF to return complicated result.
{noformat}
SELECT reflect_complicated(
NAMED_STRUCT('k1', 's', 'k2', 's'),
"org.apache.commons.lang3.StringUtils",
"split", 'v1 v2'),
reflect_complicated(
ARRAY(),
"org.apache.commons.lang3.StringUtils",
"split", 'v1 v2'),
FROM src LIMIT 1;
{noformat}
A more common use case will be add a user-created jar into hive and then call the function using reflect_complicated instead of creating a UDF.
For example,
You can create a class like below
{noformat}
package com.foo
Class Bar
{ public static Object[] genStruct(String json) {...}
}
{noformat}
And then call it from hive
{noformat}
SELECT reflect_complicated(
NAMED_STRUCT('k1', 's', 'k2', 's'),
"com.foo.Bar",
"genStruct", json) FROM ...
{noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)