我在HIVE查询中使用了用户定义的函数(我们称其为FUNC_1)。由于某些未知原因,FUNC_1在处理几行时会遇到一些问题。具体来说:
CREATE TEMPORARY FUNCTION FUNC_1 as 'org.example.letsdobigdata.func_1';
SELECT FUNC_1(col1), col2, col3
FROM EXAMPLE_TABLE;
由于FUNC_1在处理col1时遇到问题,因此报告了以下错误:
Task with the most failures(4):
-----
Task ID:
task_*********_******_*******
URL:
http://0.0.0.0:8088/*********
-----
Diagnostic Messages for this Task:
Error: java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) {"key":{"_col0":"-----","_col1":"------","_col2":"-----","_col3":---
at org.apache.hadoop.hive.ql.exec.mr.ExecReducer.reduce(ExecReducer.java:265)
at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:444)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:392)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1924)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row (tag=0) {"key":{"_col0":"-----","_col1":"------","_col2":"-----","_col3":---
at org.apache.hadoop.hive.ql.exec.mr.ExecReducer.reduce(ExecReducer.java:253)
... 7 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating FUNC_1
我想知道是否有任何故障保护机制允许该函数出错时继续运行查询?
(例如,在python中,我们可以这样做:
try:
return FUNC_1(x)
except:
return NULL
)
我们可以在HIVE中执行类似的操作(或一般而言,任何SQL风格),以便当FUNC_1(col)有错误(而不是中断整个查询ang却什么也没回来吗)时我可以得到NULL