[ https://issues.apache.org/jira/browse/HIVE-21282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16770182#comment-16770182 ]
BELUGA BEHR commented on HIVE-21282: ------------------------------------ The {{reflect}} UDF is generally considered unsafe because it allows users to execute any code they wish from the Java JDK or loaded 3rd party libraries. Better off writing a custom UDF to perform these actions. > 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 > Priority: Minor > Original Estimate: 8h > Remaining Estimate: 8h > > 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)