我正在尝试编写一个遍历hive服务器中所有数据库的脚本,并且每个数据库都返回包含具有特定名称的列的表的列表。具体而言(伪代码):
list l
for d in show databases:
use d
for tbl in show tables:
res = describe tbl | grep col_name
if res not empty:
l.append(tbl.name)
return l
我不确定如何编码。有帮助吗?如果有一些很好的参考将这些shell命令与管道等结合起来。我很感激这个建议。
答案 0 :(得分:1)
一种选择是使用mydomain.com/es-MX/path/to/page
(无论您选择哪种脚本语言):
hive -e '<hive command>'
将返回所有数据库
hive -e 'show databases'
将返回数据库hive -e 'use $d; show tables'
$d
将描述数据库hive -e 'use $d; describe $tbl'
$tbl