小智 5
如果您有 Hue 可用,您可以从顶部菜单数据浏览器转到 Metastore 表。您可以在那里找到所有可用模式的元数据。从 Hive 您可以尝试:
USE DB_NAME;
DESCRIBE FORMATTED TABLE_NAME;
或
DESCRIBE EXTENDED TABLE_NAME;
使用 Hcatlog。
Maven 依赖:
<dependency>
<groupId>org.apache.hive.hcatalog</groupId>
<artifactId>hive-webhcat-java-client</artifactId>
<version>1.2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
示例代码:
HiveConf hcatConf = new HiveConf();
hcatConf.setVar(HiveConf.ConfVars.METASTOREURIS, connectionUri);
hcatConf.set("hive.metastore.local", "false");
HCatClient client = null;
HCatTable hTable = null;
try {
client = HCatClient.create(hcatConf);
hTable = client.getTable(databaseName, tableName);
System.out.println(hTable.getLocation());
System.out.println(hTable.getInputFileFormat());
System.out.println(hTable.getOutputFileFormat());
// other properties
} catch (HCatException hCatEx) {
LOG.error("Not able to connect to hive. Caused By;", hCatEx);
}
Run Code Online (Sandbox Code Playgroud)
检查HCatTable的可用方法。