Hive - 如何将'describe table'的结果导入临时表或cte

时间:2018-01-25 16:11:04

标签: hive common-table-expression describe

我正在尝试在一堆hive表上运行describe,并希望创建一堆cte然后UNION它们。像这样:

With t1 as (describe sch1.tab1)
, t2 as (describe sch1.tab2)
, t3 as (describe sch1.tab3)
select *
from t1 UNION
select *
from t2 UNION
select * 
from t3

不幸的是,当我尝试这样做时,我收到了这个错误:

Error while compiling statement: FAILED: ParseException line 1:15 Failed to recognize predicate 'describe'. Failed rule: 'identifier' in table name 

有关如何执行此操作的任何建议吗?

1 个答案:

答案 0 :(得分:0)

您可以在.hql中添加所有describe命令,并使用sort -u命令执行UNION

hive -f desc_tables.hql  | sort -u