Question

My colleague created a table in hive and added a tricky SerDe Regex. I'd like to see what the regex is but the "SHOW CREATE TABLE" command doesn't have it.

Is there any other way to view the SERDEPROPERTIES that a table was created with?

Example:

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)

I'm using hive 0.11. Thanks!

Was it helpful?

Solution

You can do a describe extended which will show you everything about your table, including the serde properties you mentioned.

For example for your table:

$ 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)

If you look in the object returned, you can see the interesting part below:

serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.contrib.serde2.RegexSerDe, parameters:{output.format.string=%1$s, serialization.format=1, input.regex=(.*)})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top