我有一个包含大约100个表的数据库,我需要构建一个连接查询以从其中两个获取特定数据。我知道一个而不是另一个。基本上我需要这样的东西:
select <tables> from <HIVE_database> where exists table.column name;
我该怎么做?
答案 0 :(得分:0)
您可以编写一个shell脚本来搜索所有表中的列。
第一行为您提供所有表名。它被传递给read命令 并搜索每个表中的describe输出以查找列名。
$hive -e 'show tables in <HIVE_database>' | \
while read line
do
echo "TABLE NAME : $line"
eval "hive -e 'describe <HIVE_database>.$line'" | grep "<column_name>"
done