diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java index aa5f317..5da2c6b 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java @@ -176,16 +176,16 @@ private void updateColStats(Set projIndxLst) { } } + if (null == partitionList) { + // We could be here either because its an unpartitioned table or because + // there are no pruning predicates on a partitioned table. + computePartitionList(m_hiveConf, null); + } + // 2. Obtain Col Stats for Non Partition Cols if (nonPartColNamesThatRqrStats.size() > 0) { List hiveColStats; - if (null == partitionList) { - // We could be here either because its an unpartitioned table or because - // there are no pruning predicates on a partitioned table. - computePartitionList(m_hiveConf, null); - } - if (!m_hiveTblMetadata.isPartitioned()) { // 2.1 Handle the case for unpartitioned table. hiveColStats = StatsUtils.getTableColumnStats(m_hiveTblMetadata, m_hiveNonPartitionCols, diff --git ql/src/test/queries/clientpositive/cbo_correctness.q ql/src/test/queries/clientpositive/cbo_correctness.q index d1e629e..8cc5045 100644 --- ql/src/test/queries/clientpositive/cbo_correctness.q +++ ql/src/test/queries/clientpositive/cbo_correctness.q @@ -220,3 +220,6 @@ select null from t3; -- 14. unary operator select key from t1 where c_int = -6 or c_int = +6; + +-- 15. query referencing only partition columns +select count(t1.dt) from t1 join t2 on t1.dt = t2.dt where t1.dt = '2014' ; diff --git ql/src/test/results/clientpositive/cbo_correctness.q.out ql/src/test/results/clientpositive/cbo_correctness.q.out index 4f602bb..daeacd8 100644 --- ql/src/test/results/clientpositive/cbo_correctness.q.out +++ ql/src/test/results/clientpositive/cbo_correctness.q.out @@ -17894,3 +17894,20 @@ POSTHOOK: type: QUERY POSTHOOK: Input: default@t1 POSTHOOK: Input: default@t1@dt=2014 #### A masked pattern was here #### +PREHOOK: query: -- 15. query referencing only partition columns +select count(t1.dt) from t1 join t2 on t1.dt = t2.dt where t1.dt = '2014' +PREHOOK: type: QUERY +PREHOOK: Input: default@t1 +PREHOOK: Input: default@t1@dt=2014 +PREHOOK: Input: default@t2 +PREHOOK: Input: default@t2@dt=2014 +#### A masked pattern was here #### +POSTHOOK: query: -- 15. query referencing only partition columns +select count(t1.dt) from t1 join t2 on t1.dt = t2.dt where t1.dt = '2014' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@t1 +POSTHOOK: Input: default@t1@dt=2014 +POSTHOOK: Input: default@t2 +POSTHOOK: Input: default@t2@dt=2014 +#### A masked pattern was here #### +400