Index: ql/src/test/results/clientpositive/stats_empty_dyn_part.q.out =================================================================== --- ql/src/test/results/clientpositive/stats_empty_dyn_part.q.out (revision 0) +++ ql/src/test/results/clientpositive/stats_empty_dyn_part.q.out (revision 0) @@ -0,0 +1,121 @@ +PREHOOK: query: -- This test verifies writing a query using dynamic partitions +-- which results in no partitions actually being created with +-- hive.stats.reliable set to true + +create table tmptable(key string) partitioned by (part string) +PREHOOK: type: CREATETABLE +POSTHOOK: query: -- This test verifies writing a query using dynamic partitions +-- which results in no partitions actually being created with +-- hive.stats.reliable set to true + +create table tmptable(key string) partitioned by (part string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@tmptable +PREHOOK: query: explain insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value' +PREHOOK: type: QUERY +POSTHOOK: query: explain insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value' +POSTHOOK: type: QUERY +ABSTRACT SYNTAX TREE: + (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src))) (TOK_INSERT (TOK_DESTINATION (TOK_TAB (TOK_TABNAME tmptable) (TOK_PARTSPEC (TOK_PARTVAL part)))) (TOK_SELECT (TOK_SELEXPR (TOK_TABLE_OR_COL key)) (TOK_SELEXPR (TOK_TABLE_OR_COL value))) (TOK_WHERE (= (TOK_TABLE_OR_COL key) 'no_such_value')))) + +STAGE DEPENDENCIES: + Stage-1 is a root stage + Stage-7 depends on stages: Stage-1 , consists of Stage-4, Stage-3, Stage-5 + Stage-4 + Stage-0 depends on stages: Stage-4, Stage-3, Stage-6 + Stage-2 depends on stages: Stage-0 + Stage-3 + Stage-5 + Stage-6 depends on stages: Stage-5 + +STAGE PLANS: + Stage: Stage-1 + Map Reduce + Alias -> Map Operator Tree: + src + TableScan + alias: src + Filter Operator + predicate: + expr: (key = 'no_such_value') + type: boolean + Select Operator + expressions: + expr: key + type: string + expr: value + type: string + outputColumnNames: _col0, _col1 + File Output Operator + compressed: false + GlobalTableId: 1 + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + name: default.tmptable + + Stage: Stage-7 + Conditional Operator + + Stage: Stage-4 + Move Operator + files: + hdfs directory: true +#### A masked pattern was here #### + + Stage: Stage-0 + Move Operator + tables: + partition: + part + replace: true + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + name: default.tmptable + + Stage: Stage-2 + Stats-Aggr Operator + + Stage: Stage-3 + Map Reduce + Alias -> Map Operator Tree: +#### A masked pattern was here #### + File Output Operator + compressed: false + GlobalTableId: 0 + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + name: default.tmptable + + Stage: Stage-5 + Map Reduce + Alias -> Map Operator Tree: +#### A masked pattern was here #### + File Output Operator + compressed: false + GlobalTableId: 0 + table: + input format: org.apache.hadoop.mapred.TextInputFormat + output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat + serde: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe + name: default.tmptable + + Stage: Stage-6 + Move Operator + files: + hdfs directory: true +#### A masked pattern was here #### + + +PREHOOK: query: insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value' +PREHOOK: type: QUERY +PREHOOK: Input: default@src +PREHOOK: Output: default@tmptable +POSTHOOK: query: insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src Index: ql/src/test/queries/clientpositive/stats_empty_dyn_part.q =================================================================== --- ql/src/test/queries/clientpositive/stats_empty_dyn_part.q (revision 0) +++ ql/src/test/queries/clientpositive/stats_empty_dyn_part.q (revision 0) @@ -0,0 +1,13 @@ +-- This test verifies writing a query using dynamic partitions +-- which results in no partitions actually being created with +-- hive.stats.reliable set to true + +create table tmptable(key string) partitioned by (part string); + +set hive.stats.autogather=true; +set hive.stats.reliable=true; +set hive.exec.dynamic.partition.mode=nonstrict; + +explain insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value'; + +insert overwrite table tmptable partition (part) select key, value from src where key = 'no_such_value'; Index: ql/src/java/org/apache/hadoop/hive/ql/exec/StatsTask.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/exec/StatsTask.java (revision 1384170) +++ ql/src/java/org/apache/hadoop/hive/ql/exec/StatsTask.java (working copy) @@ -541,10 +541,13 @@ } DynamicPartitionCtx dpCtx = tbd.getDPCtx(); if (dpCtx != null && dpCtx.getNumDPCols() > 0) { // dynamic partitions - // load the list of DP partitions and return the list of partition specs - for (LinkedHashMap partSpec : dpPartSpecs) { - Partition partn = db.getPartition(table, partSpec, false); - list.add(partn); + // If no dynamic partitions are generated, dpPartSpecs may not be initialized + if (dpPartSpecs != null) { + // load the list of DP partitions and return the list of partition specs + for (LinkedHashMap partSpec : dpPartSpecs) { + Partition partn = db.getPartition(table, partSpec, false); + list.add(partn); + } } } else { // static partition Partition partn = db.getPartition(table, tbd.getPartitionSpec(), false);