【发布时间】:2016-04-20 07:10:46
【问题描述】:
在下面的代码中,每当捕获到异常时,我想退出程序并在 shell 上打印异常
#stream.py
import hashlib
import sys
import os
import importlib
for line in sys.stdin.readlines():
try:
inpFile = "temp.py"
execfile(inpFile)
line1 = line.strip('\n').split('\t')
print "\t".join(line1)
except:
#exception expected "temp.py:File Not Found", how do I exit the code & print the exception on console ?
sys.exit(1)
这里是调用 UDF 的转换查询:
创建表 newtable as Select TRANSFORM(id,name) USING 'python stream.py' as (id,name) from mytable;
想法赞赏。
【问题讨论】: