场景:通过parseHtml UDF解析一串HTML,返回一以 @@ 分割的字符串,使用split分割字符串进数组中,然后将数组的元素转列。

开始的写法

SELECT
id,
legal_person,
explode(split(parseHtml(legal_person_track_record),'@@')) as record,
amac_status
FROM db_amac.dc_amac_manager limit 10;

--问题
FAILED: SemanticException [Error 10081]: UDTF's are not supported outside the SELECT clause, nor nested in expressions

解决

select
id,
legal_person,
record,
amac_status
from db_amac.dc_amac_manager lateral view explode(split(parseHtml(legal_person_track_record),'@@')) recordTable as record;

Lateral View是Hive中提供给UDTF的conjunction,它可以解决UDTF不能添加额外的select列的问题。

 

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
  • 2021-09-24
  • 2022-12-23
  • 2021-05-31
  • 2021-06-18
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-12-05
相关资源
相似解决方案