【发布时间】:2016-12-07 18:52:01
【问题描述】:
有没有办法在 Hive 中运行“描述扩展表”并以JSON、XML 或一些易于解析的格式返回结果?或者Java中是否存在可以解析这种格式的现有解析?
表(表名:test3,dbName:testdatabase,所有者:johnsmith,createTime:1481135997,lastAccessTime:0,retention:0,sd:StorageDescriptor(cols:[FieldSchema(名称:a,类型:字符串,注释:“” a,m)],位置:hdfs://testcluster/apps/hive/warehouse/testdatabase/test3,输入格式:org.apache.hadoop.hive.ql.io.orc.OrcInputFormat,输出格式:org.apache.hadoop。 hive.ql.io.orc.OrcOutputFormat,compressed:false,numBuckets:-1,serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.ql.io.orc.OrcSerde, parameters:{serialization. format=1}), bucketCols:[], sortCols:[], 参数:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[] , 参数:{totalSize=0, numRows=0, rawDataSize=0, COLUMN_STATS_ACCURATE={"BASIC_STATS":"true"}, numFiles=0, transient_lastDdlTime=1481135997}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)
【问题讨论】:
-
对于人类来说,SHOW CREATE TABLE 更具可读性(恕我直言——以我的拙见)
-
如果您真的想访问 Java 中的原始信息,请尝试使用 Metastore API - 文档很少,但使用真实的东西hive.apache.org/javadocs/r1.1.1/api/org/apache/hadoop/hive/… (调整到您的实际 Hive 版本使用)
-
另一种选择是访问同样是 SQL 的 Metastore (!)...但是it is possible with beeline?