5

我的同事在 hive 中创建了一个表并添加了一个棘手的 SerDe Regex。我想看看正则表达式是什么,但“SHOW CREATE TABLE”命令没有它。

有没有其他方法可以查看创建表的 SERDEPROPERTIES?

例子:

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)

我正在使用配置单元 0.11。谢谢!

4

1 回答 1

8

您可以执行一个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=(.*)})
于 2013-10-31T20:27:46.570 回答