2016-10-24 9 views

答えて

1

あなたが他のSELECT文を送ってしまうとあなたは、サーバーへのdescribe formatted <tableName>文を送ることができますthis code example を見てみます。

+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> 

サンプルコード:

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

HCatTableの他の方法を確認してください。

+0

ありがとう、私はユースケースのためにHCatを使用することはできません。 – VoodooChild

関連する問題