Description
When use rand function with null, HiveServer throws NPE:
0: jdbc:hive2://10.64.35.144:21066/> desc foo1; +-----------+------------+----------+--+ | col_name | data_type | comment | +-----------+------------+----------+--+ | c1 | bigint | | +-----------+------------+----------+--+ 1 row selected (0.075 seconds) 0: jdbc:hive2://10.64.35.144:21066/> select * from foo1; +----------+--+ | foo1.c1 | +----------+--+ | NULL | | 1 | | 2 | +----------+--+ 3 rows selected (0.124 seconds) 0: jdbc:hive2://10.64.35.144:21066/> select rand(c1) from foo1; Error: java.io.IOException: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method public org.apache.hadoop.hive.serde2.io.DoubleWritable org.apache.hadoop.hive.ql.udf.UDFRand.evaluate(org.apache.hadoop.io.LongWritable) on object org.apache.hadoop.hive.ql.udf.UDFRand@37a2b47b of class org.apache.hadoop.hive.ql.udf.UDFRand with arguments {null} of size 1 (state=,code=0)
Stack trace:
Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.hive.ql.exec.FunctionRegistry.invoke(FunctionRegistry.java:1010) ... 36 more Caused by: java.lang.NullPointerException at org.apache.hadoop.hive.ql.udf.UDFRand.evaluate(UDFRand.java:57) ... 40 more