如何在Hive表中搜索列存在

时间:2016-10-05 17:09:18

标签: hive

hive表,大约有50列。使用Describe命令或运行select命令查找特定内容变得乏味。

有没有办法可以在Hive表中搜索列的存在?

而且,我们可以在列名中使用substring而不是更有用的完整名称。

先谢谢。

1 个答案:

答案 0 :(得分:0)

我相信没有命令可以直接检查,但您有以下选项。

1) Query column name , if you get NOT FOUND exception , the column doesn't exist.
2) Describe first , iterate through results and search for the column you are looking for.
3) Use Hive meta store client and get HiveMetastoreClient.getFields ,this will give list of columns ,iterate and search for your column