2016-10-24 51 views

回答

1

看着this code example 您可以发送describe formatted <tableName>声明服务器,你会发出任何其他SELECT声明。

+0

任何干净的方式来获取分区列信息? – VoodooChild

+0

您可以发送'描述格式'声明。 –

1

我发现更好的方法是在这种情况下使用hcatalog

Maven的依赖性:

<dependency> 
     <groupId>org.apache.hive.hcatalog</groupId> 
     <artifactId>hive-webhcat-java-client</artifactId> 
     <version>1.2.1</version> 
    </dependency> 

示例代码:的HCatTable

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()); 

} catch (HCatException hCatEx) { 
    LOG.error("Not able to connect to hive. Caused By;", hCatEx); 
} 

检查等方法。

+0

非常感谢,但我无法使用HCat作为我的用例。 – VoodooChild