【发布时间】:2013-12-17 21:35:45
【问题描述】:
我正在寻找调试 Python UDF 的最佳实践。
我无法运行此 UDF,也无法在日志中显示有价值的错误消息。
此函数将“DD-MON-YY”格式的日期作为输入(例如,“01-JAN-2013”)并返回当天发生的那一周作为输出(对于“01-JAN -2013',这将是一年中的第零周,因此返回值为 0)。
@outputSchema("week_number:int")
def week_from_date(input_date):
date_to_match = re.match('(\d{2}).?([A-Za-z]{3}).?(\d{4})', input_date)
if date_to_match:
day, month, year = date_to_match.group(1), date_to_match.group(2), date_to_match.group(3)
import time
from time import gmtime, strftime
d = time.strptime("%s %s %s" % (day, month, year), "%d %b %Y")
return int(strftime("%U", d))
else:
return -1
我收到此错误:Backend error : Error executing function
是否有更多描述性的错误信息?调试 Python UDF 的最佳实践是什么?
【问题讨论】:
标签: python regex user-defined-functions apache-pig