如何在Hive的所有表中找到特定的列名?

编程入门 行业动态 更新时间:2024-10-27 06:33:24
本文介绍了如何在Hive的所有表中找到特定的列名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何在Hive的所有表中找到特定的列名?

How can I find a particular column name within all tables in Hive?

我在配置单元中运行了此查询:select table_name,column_name from retail.columns where column_name like '%emp%';(零售是一个数据库).

I ran this query in hive: select table_name,column_name from retail.columns where column_name like '%emp%'; (retail is a database).

但是它给出了:

错误失败:SemanticException行0:-1找不到表列"

error FAILED: SemanticException Line 0:-1 Table not found 'columns'

我尝试查询:select distinct table_name from default.columns where column_name = 'emp'(默认是我的数据库).但这也给了错误.

I tried query: select distinct table_name from default.columns where column_name = 'emp' (default is mine database). But it's also giving error.

我搜索了这些,得到了我写的用于SQL数据库的查询.

I searched about these, I got which query I wrote it's for SQL databases.

但是我想在配置单元数据库中搜索?如何进入蜂巢?

But I want to search in hive database? How to get in hive?

之前也曾问过同样的问题,但我认为情况可能已经改变,可能会有直接的解决方案:

The same question has been asked before but I feel things might have changed and there might be direct solution:

如何在Hadoop/Hive中搜索具有给定列名的所有表并返回具有该列名的表?

在Hive中搜索表和列

推荐答案

以下shell脚本将为您提供所需的结果:

below shell script will give you desired result:

hive -S -e 'show databases'| while read database do eval "hive -S -e 'show tables in $database'"| while read line do if eval "hive -S -e 'describe $database.$line'"| grep -q "<column_name"; then output="Required table name: $database.$line"'\n'; else output=""'\n'; fi echo -e "$output" done done

更多推荐

如何在Hive的所有表中找到特定的列名?

本文发布于:2023-11-29 19:27:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647402.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中找到   如何在   Hive

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!