如何获取现有配置单元表的serde属性

eanckbw9  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(254)

我的同事在hive中创建了一个表,并添加了一个复杂的serde正则表达式。我想看看regex是什么,但是“showcreatetable”命令没有它。
有没有其他方法可以查看创建表时使用的serdeProperty?
例子:

hive> CREATE TABLE foo (
  bar STRING
) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
WITH SERDEPROPERTIES ( "input.regex" = "(.*)", "output.format.string" = "%1$s" );

OK
Time taken: 0.078 seconds

hive> SHOW CREATE TABLE foo;
OK
CREATE  TABLE foo(
  bar string COMMENT 'from deserializer')
ROW FORMAT DELIMITED
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  'maprfs:/user/hive/warehouse/foo'
TBLPROPERTIES (
  'transient_lastDdlTime'='1383248078')
Time taken: 0.091 seconds, Fetched: 11 row(s)

我用的是Hive0.11。谢谢!

4si2a6ki

4si2a6ki1#

你可以做一个 describe extended 它将向您展示表的所有内容,包括您提到的serde属性。
例如,对于您的表:

$ hive -e "describe extended foo"
Detailed Table Information  Table(tableName:foo, dbName:default, owner:cloudera, createTime:1383250992, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:bar, type:string, comment:null)], location:hdfs://localhost.localdomain:8020/user/hive/warehouse/foo, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.contrib.serde2.RegexSerDe, parameters:{output.format.string=%1$s, serialization.format=1, input.regex=(.*)}), bucketCols:[], sortCols:[], parameters:{}, skewedInfo:SkewedInfo(skewedColNames:[], skewedColValues:[], skewedColValueLocationMaps:{}), storedAsSubDirectories:false), partitionKeys:[], parameters:{transient_lastDdlTime=1383250992}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)

如果查看返回的对象,可以看到下面有趣的部分:

serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.contrib.serde2.RegexSerDe, parameters:{output.format.string=%1$s, serialization.format=1, input.regex=(.*)})

相关问题