diff --git ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java index 1360e74..f0cc43f 100644 --- ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java +++ ql/src/java/org/apache/hadoop/hive/ql/metadata/Partition.java @@ -45,6 +45,7 @@ import org.apache.hadoop.hive.ql.io.HiveFileFormatUtils; import org.apache.hadoop.hive.ql.io.HiveOutputFormat; import org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat; import org.apache.hadoop.hive.serde2.Deserializer; +import org.apache.hadoop.hive.serde2.SerDeUtils; import org.apache.hadoop.mapred.InputFormat; import org.apache.thrift.TException; import org.apache.thrift.protocol.TBinaryProtocol; @@ -198,7 +199,7 @@ public class Partition implements Serializable { } } // set default if columns are not set - if (tPartition.getSd().getCols() == null || tPartition.getSd().getCols().size() == 0) { + if (tPartition.getSd().getCols() == null) { if (table.getCols() != null) { tPartition.getSd().setCols(table.getCols()); } @@ -502,7 +503,19 @@ public class Partition implements Serializable { } public List getCols() { - return tPartition.getSd().getCols(); + if (!SerDeUtils.shouldGetColsFromSerDe( + tPartition.getSd().getSerdeInfo().getSerializationLib())) { + return tPartition.getSd().getCols(); + } + + try { + return Hive.getFieldsFromDeserializer(table.getTableName(), getDeserializer()); + } catch (HiveException e) { + LOG.error("Unable to get cols from serde: " + + tPartition.getSd().getSerdeInfo().getSerializationLib(), e); + } + + return new ArrayList(); } public String getLocation() { diff --git ql/src/test/queries/clientpositive/serde_reported_schema.q ql/src/test/queries/clientpositive/serde_reported_schema.q index e20dfae..01ec864 100644 --- ql/src/test/queries/clientpositive/serde_reported_schema.q +++ ql/src/test/queries/clientpositive/serde_reported_schema.q @@ -4,6 +4,6 @@ create table int_string with serdeproperties ( "serialization.class"="org.apache.hadoop.hive.serde2.thrift.test.IntString", "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol"); -describe int_string; +describe extended int_string; alter table int_string add partition (b='part1'); -describe int_string partition (b='part1'); \ No newline at end of file +describe extended int_string partition (b='part1'); diff --git ql/src/test/results/clientpositive/serde_reported_schema.q.out ql/src/test/results/clientpositive/serde_reported_schema.q.out index 6fac935..4810512 100644 --- ql/src/test/results/clientpositive/serde_reported_schema.q.out +++ ql/src/test/results/clientpositive/serde_reported_schema.q.out @@ -13,14 +13,16 @@ POSTHOOK: query: create table int_string "serialization.format"="org.apache.thrift.protocol.TBinaryProtocol") POSTHOOK: type: CREATETABLE POSTHOOK: Output: default@int_string -PREHOOK: query: describe int_string +PREHOOK: query: describe extended int_string PREHOOK: type: DESCTABLE -POSTHOOK: query: describe int_string +POSTHOOK: query: describe extended int_string POSTHOOK: type: DESCTABLE myint int from deserializer mystring string from deserializer underscore_int int from deserializer b string + +#### A masked pattern was here #### PREHOOK: query: alter table int_string add partition (b='part1') PREHOOK: type: ALTERTABLE_ADDPARTS PREHOOK: Input: default@int_string @@ -28,11 +30,13 @@ POSTHOOK: query: alter table int_string add partition (b='part1') POSTHOOK: type: ALTERTABLE_ADDPARTS POSTHOOK: Input: default@int_string POSTHOOK: Output: default@int_string@b=part1 -PREHOOK: query: describe int_string partition (b='part1') +PREHOOK: query: describe extended int_string partition (b='part1') PREHOOK: type: DESCTABLE -POSTHOOK: query: describe int_string partition (b='part1') +POSTHOOK: query: describe extended int_string partition (b='part1') POSTHOOK: type: DESCTABLE myint int from deserializer mystring string from deserializer underscore_int int from deserializer b string + +#### A masked pattern was here ####