Repository: hive Updated Branches: refs/heads/branch-1.0 8026f3914 -> d7fef488b
HIVE-6308 : COLUMNS_V2 Metastore table not populated for tables created without an explicit column list. (Yongzhi Chen via Szehon) git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1655213 13f79535-47bb-0310-9956-ffa450edef68 Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/d7fef488 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/d7fef488 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/d7fef488 Branch: refs/heads/branch-1.0 Commit: d7fef488b455f8136021ac0e58c70998bd6fc6b9 Parents: 8026f39 Author: Szehon Ho <sze...@apache.org> Authored: Wed Jan 28 02:49:20 2015 +0000 Committer: Pengcheng Xiong <pxi...@apache.org> Committed: Wed Sep 2 16:54:48 2015 -0700 ---------------------------------------------------------------------- data/files/grad.avsc | 12 +++++ .../apache/hadoop/hive/ql/metadata/Hive.java | 2 +- .../queries/clientpositive/compustat_avro.q | 15 ++++++ .../results/clientpositive/compustat_avro.q.out | 52 ++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/d7fef488/data/files/grad.avsc ---------------------------------------------------------------------- diff --git a/data/files/grad.avsc b/data/files/grad.avsc new file mode 100644 index 0000000..0f12e60 --- /dev/null +++ b/data/files/grad.avsc @@ -0,0 +1,12 @@ +{"namespace": "devmode", +"type": "record", +"name": "gradinfo", +"fields": [ +{"name": "col1", "type": "string"}, +{"name": "col2", "type": "string"}, +{"name": "col3", "type": "double"}, +{"name": "col4", "type": "string"}, +{"name": "col5", "type": "string"}, +{"name": "col6", "type": "int"} +] +} http://git-wip-us.apache.org/repos/asf/hive/blob/d7fef488/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java ---------------------------------------------------------------------- diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java index 8c8cb4f..fee47e0 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java @@ -648,7 +648,7 @@ public class Hive { if (tbl.getDbName() == null || "".equals(tbl.getDbName().trim())) { tbl.setDbName(SessionState.get().getCurrentDatabase()); } - if (tbl.getCols().size() == 0) { + if (tbl.getCols().size() == 0 || tbl.getSd().getColsSize() == 0) { tbl.setFields(MetaStoreUtils.getFieldsFromDeserializer(tbl.getTableName(), tbl.getDeserializer())); } http://git-wip-us.apache.org/repos/asf/hive/blob/d7fef488/ql/src/test/queries/clientpositive/compustat_avro.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientpositive/compustat_avro.q b/ql/src/test/queries/clientpositive/compustat_avro.q new file mode 100644 index 0000000..4d1b604 --- /dev/null +++ b/ql/src/test/queries/clientpositive/compustat_avro.q @@ -0,0 +1,15 @@ +drop table if exists testAvro; +create table testAvro + ROW FORMAT SERDE + 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' + STORED AS INPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' + OUTPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' + TBLPROPERTIES ('avro.schema.url'='file://${system:hive.root}data/files/grad.avsc'); + +describe formatted testAvro.col1; + +analyze table testAvro compute statistics for columns col1,col3; + +describe formatted testAvro.col1; http://git-wip-us.apache.org/repos/asf/hive/blob/d7fef488/ql/src/test/results/clientpositive/compustat_avro.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientpositive/compustat_avro.q.out b/ql/src/test/results/clientpositive/compustat_avro.q.out new file mode 100644 index 0000000..8422108 --- /dev/null +++ b/ql/src/test/results/clientpositive/compustat_avro.q.out @@ -0,0 +1,52 @@ +PREHOOK: query: drop table if exists testAvro +PREHOOK: type: DROPTABLE +POSTHOOK: query: drop table if exists testAvro +POSTHOOK: type: DROPTABLE +PREHOOK: query: create table testAvro + ROW FORMAT SERDE + 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' + STORED AS INPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' + OUTPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' +#### A masked pattern was here #### +PREHOOK: type: CREATETABLE +PREHOOK: Output: database:default +PREHOOK: Output: default@testAvro +POSTHOOK: query: create table testAvro + ROW FORMAT SERDE + 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' + STORED AS INPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' + OUTPUTFORMAT + 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' +#### A masked pattern was here #### +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: database:default +POSTHOOK: Output: default@testAvro +PREHOOK: query: describe formatted testAvro.col1 +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@testavro +POSTHOOK: query: describe formatted testAvro.col1 +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@testavro +# col_name data_type min max num_nulls distinct_count avg_col_len max_col_len num_trues num_falses comment + +col1 string from deserializer +PREHOOK: query: analyze table testAvro compute statistics for columns col1,col3 +PREHOOK: type: QUERY +PREHOOK: Input: default@testavro +#### A masked pattern was here #### +POSTHOOK: query: analyze table testAvro compute statistics for columns col1,col3 +POSTHOOK: type: QUERY +POSTHOOK: Input: default@testavro +#### A masked pattern was here #### +PREHOOK: query: describe formatted testAvro.col1 +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@testavro +POSTHOOK: query: describe formatted testAvro.col1 +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@testavro +# col_name data_type min max num_nulls distinct_count avg_col_len max_col_len num_trues num_falses comment + +col1 string 0 0 0.0 0 from deserializer