Support Questions

Find answers, ask questions, and share your expertise
Announcements
Now Live: Explore expert insights and technical deep dives on the new Cloudera Community BlogsRead the Announcement

Hive reflect function is not allowed

avatar
Frequent Visitor

on Sandbox 2.3.2, the following hive query errors out:

SELECT reflect("java.lang.String", "valueOf", 1), reflect("java.lang.String", "isEmpty"), reflect("java.lang.Math", "max", 2, 3), reflect("java.lang.Math", "min", 2, 3), reflect("java.lang.Math", "round", 2.5), reflect("java.lang.Math", "exp", 1.0), reflect("java.lang.Math", "floor", 1.9) FROM hyhelp LIMIT 1;

error message is:

Error while compiling statement: FAILED: SemanticException UDF reflect is not allowed

hiveserver2.log shows:

2016-02-10 22:51:23,461 ERROR [HiveServer2-Handler-Pool: Thread-46]: ql.Driver (SessionState.java:printError(960)) - FAILED: SemanticException UDF reflect is not allowed org.apache.hadoop.hive.ql.parse.SemanticException: UDF reflect is not allowed at org.apache.hadoop.hive.ql.exec.Registry.getFunctionInfo(Registry.java:245) at org.apache.hadoop.hive.ql.exec.FunctionRegistry.getFunctionInfo(FunctionRegistry.java:463) at org.apache.hadoop.hive.ql.exec.FunctionRegistry.impliesOrder(FunctionRegistry.java:1521) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.doPhase1GetAllAggregations(SemanticAnalyzer.java:530) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.doPhase1GetAggregationsFromSelect(SemanticAnalyzer.java:465) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.doPhase1(SemanticAnalyzer.java:1145) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.doPhase1(SemanticAnalyzer.java:1415) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.doPhase1(SemanticAnalyzer.java:1415) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genResolvedParseTree(SemanticAnalyzer.java:10048) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10106) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:211) at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:227) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:424)

....

Is this a configuration issue or there are jar files missing?

Thanks

1 ACCEPTED SOLUTION

avatar
Master Guru

Hi @Herman Yu, on my Sandbox, also HDP-2.3.2 it works, I only changed table name:

hive> SELECT reflect("java.lang.String", "valueOf", 1), reflect("java.lang.String", "isEmpty"), reflect("java.lang.Math", "max", 2, 3), reflect("java.lang.Math", "min", 2, 3), reflect("java.lang.Math", "round", 2.5), reflect("java.lang.Math", "exp", 1.0), reflect("java.lang.Math", "floor", 1.9) FROM st2 limit 1;
OK
1	true	3	2	3	2.718281828459045	1.0
Time taken: 1.97 seconds, Fetched: 1 row(s)

Do other Hive commands and scripts work? Can you try reflect one by one, or, if you copy/pasted the command from somewhere try typing the first reflect.

View solution in original post

5 REPLIES 5

avatar
Master Guru

Hi @Herman Yu, on my Sandbox, also HDP-2.3.2 it works, I only changed table name:

hive> SELECT reflect("java.lang.String", "valueOf", 1), reflect("java.lang.String", "isEmpty"), reflect("java.lang.Math", "max", 2, 3), reflect("java.lang.Math", "min", 2, 3), reflect("java.lang.Math", "round", 2.5), reflect("java.lang.Math", "exp", 1.0), reflect("java.lang.Math", "floor", 1.9) FROM st2 limit 1;
OK
1	true	3	2	3	2.718281828459045	1.0
Time taken: 1.97 seconds, Fetched: 1 row(s)

Do other Hive commands and scripts work? Can you try reflect one by one, or, if you copy/pasted the command from somewhere try typing the first reflect.

avatar
Master Guru

It also works with standard Hue-2.6.1 packaged with HDP-2.3.4 (that's the only one I can try; it should also work with Hue coming with 2.3.2 because it's the same version), I tried:

SELECT reflect("java.lang.Math","exp",2.0), reflect("java.lang.Math","hypot",3.0,4.0) from t2 limit 1;

2076-reflect1.png

avatar
New Member

Does not work for me either.

avatar
Frequent Visitor

Thanks, I think it is a configuration issue. it doesn't work with a customized Hue I installed, doesn't work with Ambari Hive view either, but does work with Hive CLI. I found a walk-around for now, will figure out the configurations later when have time.

thanks.

avatar
New Member

I am still unable to get this to work. All I am doing is trying to run the query, is there something I need to do in order to get this to work?