使用 Java API 从 Hive 中获取表属性 [英] Get Table Properties out of Hive using Java API
问题描述
我正在尝试使用 java 中的 Metastore 客户端从 hive Metastore 中获取表属性,例如表 db、名称、所有者和 hdfs 位置.我想我可以得到表数据库和名称,但是我不知道如何获取所有者和 hdfs 位置之类的东西.是否可以?我一直在搜索文档和互联网几个小时,但没有骰子.
I'm trying to get table properties like table db, name, owner, and hdfs location out of the hive metastore using the metastore client in java. I think I can get the table databases and names okay, but I can't figure out how to grab things like owner and hdfs location. Is it possible? I've been searching the doc and internet for a couple hours now and no dice.
推荐答案
可能是这样的:
org.apache.hadoop.hive.metastore.api.Table table=..........;
org.apache.hadoop.hive.metastore.api.StorageDescriptor sd=table.getSd();
String loc=sd.getLocation();
String own=sd.getOwner();
https://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/metastore/api/Table.htmlhttps://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/metastore/api/StorageDescriptor.html
这篇关于使用 Java API 从 Hive 中获取表属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!