Sql 使用Hiveql计算表的列

Sql 使用Hiveql计算表的列,sql,powershell,shell,hiveql,Sql,Powershell,Shell,Hiveql,我正在尝试使用配置单元计算每个表的列数 为了查找列,我使用了查询“ShowColumns in tablename”,然后使用以下命令: hive -e 'show columns in tablename' | grep -v 'WARN' (to remove the warning from the count ) | wc -l 它给了我正确的结果 但当我尝试对许多表运行此命令时,该命令会给出所有列的总和 以下是我所做的: 1-创建了一个hql文件,其中包含以下所有查询: sh

我正在尝试使用配置单元计算每个表的列数

为了查找列,我使用了查询“ShowColumns in tablename”,然后使用以下命令:

    hive -e 'show columns in tablename' | grep -v 'WARN' (to remove the warning from the count ) | wc -l
它给了我正确的结果

但当我尝试对许多表运行此命令时,该命令会给出所有列的总和

以下是我所做的:

1-创建了一个hql文件,其中包含以下所有查询:

show columns in tablename1;
show columns in tablename2;
然后,我使用了相同的命令,但没有使用hive-e,而是使用了hive-f:

hive -f file.hql | grep -v 'WARN'  | wc -l
结果只有一行,似乎是所有列的总和

我想要的是:

tablename 1 columnsumber1

tablename 2 columnsumber2

找到了它:

cat queries.txt | while read line; do eval "hive -e $line" | grep -v WARN | wc -l ; done > outpux.txt

在shell脚本中编写循环?每个表一次迭代,允许每个表运行一次初始命令?为什么标记powershell?