【问题标题】:UDF python in Hive with File Json带有文件 Json 的 Hive 中的 UDF python
【发布时间】:2018-06-15 07:58:03
【问题描述】:

我在 Ambari 中的 Hive 视图有两个问题。

1.问题1:我有脚本:

<br>DELETE FILE /user/admin/hive/scripts/MKT_UDF/fb_audit_ads_creatives.py;
<br>ADD FILE /user/admin/hive/scripts/MKT_UDF/fb_audit_ads_creatives.py;
<br>SELECT TRANSFORM (line) USING 'python fb_audit_ads_creatives.py' as (ad_id) FROM stg_fb_audit_ads_creatives_json where date_time='2018-05-05';

我运行了很多次,运行流畅。但有时,我会收到错误:

你可以看到它:这里是Log error
我认为这是由于配置(Hive、Ambari、...超时...v.v.)

问题 2:我有文件 json:

{
  "body": "https://www.facebook.com/groupkiemhieptinhduyen #truongsinhquyet #sapramat #tsq #game3d",
  "thumbnail_url": "https://external.xx.fbcdn.net/safe_image.php?d=AQDU01asRxdnCObW&w=64&h=64&url=https%3A%2F%2Fscontent.xx.fbcdn.net%2Fv%2Ft15.0-10%",
  "campaign_id": "23842841688740666"
}

我使用上面的脚本 HQL 和 UDF Python:

for line in sys.stdin:
data = json.loads(line)
print (data)
print(data['thumbnail_url']


我运行没问题。

但使用 UDF Python:

for line in sys.stdin:
data = json.loads(line)
print (data)
print(data['body']


我收到错误: Log error


你能帮帮我吗?

【问题讨论】:

    标签: hadoop hive user-defined-functions hiveql ambari


    【解决方案1】:

    我建议不要使用 python,而是尝试使用这个 UDTF,它允许在 json columns within hive 上工作,然后可以操作大型 json 并以分布式和优化的方式获取所需的数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-12
      • 2016-03-29
      • 1970-01-01
      • 2019-09-18
      • 1970-01-01
      • 2016-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多