gpt4 book ai didi

python - Hive Python UDF

转载 作者:行者123 更新时间:2023-12-02 19:21:06 28 4
gpt4 key购买 nike

我正在使用此Python UDF脚本:

import sys
import collections
import datetime
import re

try:
for line in sys.stdin:
line=line.strip()
number,sd=line.split('\t')
sd=sd.lower()
sd=sd.split(' ')
new_sd_list=collections.OrderedDict(collections.Counter(sd))
new_sd=' '.join(new_sd_list)
print('\t'.join([str(number),str(new_sd])))
except:
print(sys.exc_info())
在Putty中执行以下命令。
SELECT TRANSFORM(number,shortdescription) USING 'python name.py' \
AS (number,shortdescription) FROM table;
我收到此错误:

Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row {"number": "ABC00548","shortdescription":""Master data inconsistency check in India Optimizer."}

FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTaskMapReduce Jobs Launched:Stage-Stage-1: Map: 4 HDFS Read: 0 HDFS Write: 0 FAILTotal MapReduce CPU Time Spent: 0 msec

最佳答案

import sys
import collections
import datetime
import re

try:
for line in sys.stdin:
line=line.strip()
number,sd=line.split('\t')
sd=sd.lower()
sd=sd.split(' ')
new_sd_list=collections.OrderedDict(collections.Counter(sd))
new_sd=' '.join(new_sd_list)
print('\t'.join([str(number),str(new_sd)])) #syntax error
except:
print(sys.exc_info())

关于python - Hive Python UDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46031510/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com