pom相关性:
<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");
hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, THRIFT_CONNECTION_RETRY);
hcatConf.set(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY.varname, "true");
hcatConf.set(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK.varname, HCatSemanticAnalyzer.class.getName());
hcatConf.set(HiveConf.ConfVars.PREEXECHOOKS.varname, "");
hcatConf.set(HiveConf.ConfVars.POSTEXECHOOKS.varname, "");
hcatConf.setTimeVar(HiveConf.ConfVars.METASTORE_CLIENT_SOCKET_TIMEOUT, TIME_OUT, TimeUnit.MILLISECONDS);
HCatClient client = null;
HCatTable hTable = null;
try {
client = HCatClient.create(hcatConf);
hTable = client.getTable(databaseName, tableName);
System.out.println(hTable.getInputFileFormat());
System.out.println(hTable.getOutputFileFormat());
System.out.println(hTable.getSerdeLib());
} catch (HCatException hCatEx) {
LOG.error("Not able to connect to hive. Caused By;", hCatEx);
}
如何获取文本表的行和字段分隔符?
根据getserdeparams()的javadoc, public Map<String,String> getSerdeParams()
-返回字段分隔符等参数。
但就我而言,这张Map上只有一个条目
{serialization.format=1}
1条答案
按热度按时间flvlnr441#
如果我创建一个表:
当我跑的时候
show create table tbl1
:不显示默认分隔符。
创建带分隔符的表时:
当我跑的时候
show create table tbl2
:在第二种情况下,我明确提到了分隔符。所以,
getSerdeParams()
返回所需的值。