我正在使用UDF在我的指定日期添加一个小时,并在我的配置单元查询中将其用作过滤条件。但它给我低于错误。
FAILED: ParseException line 8:4 cannot recognize input near 'TRANSFORM' '(' '"201606161340"' in expression specification
我的hive查询是:
add file adddate.py;
select
dt,param2
from
my_table
where
dt>=TRANSFORM("201606161340") USING adddate.py and parm1="465";
我的python代码是
from datetime import datetime, timedelta
import sys
import string
def add_date(current_date):
date_object = datetime.strptime(current_date, '%Y%m%d%H%M')
# print(date_object)
one_hour = date_object + timedelta(hours=1)
return one_hour.strftime('%Y%m%d%H%M')
# addDate("201606152350")
while True:
line = sys.stdin.readline()
if not line:
break
line = string.strip(line, "\n ")
print(add_date(line))