Index: ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java (revision 1614519) +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/RelOptHiveTable.java (working copy) @@ -180,7 +180,7 @@ } else { // 2.2 Obtain col stats for full table scan Statistics stats = StatsUtils.collectStatistics(m_hiveConf, partitionList, - m_hiveTblMetadata, m_hiveNonPartitionCols, nonPartColNamesThatRqrStats); + m_hiveTblMetadata, m_hiveNonPartitionCols, nonPartColNamesThatRqrStats, true, true); m_rowCount = stats.getNumRows(); hiveColStats = new ArrayList(); for (String c : nonPartColNamesThatRqrStats) { Index: ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java (revision 1614519) +++ ql/src/java/org/apache/hadoop/hive/ql/stats/StatsUtils.java (working copy) @@ -107,19 +107,27 @@ // column level statistics are required only for the columns that are needed List schema = tableScanOperator.getSchema().getSignature(); List neededColumns = tableScanOperator.getNeededColumns(); - + return collectStatistics(conf, partList, table, schema, neededColumns); } - public static Statistics collectStatistics(HiveConf conf, PrunedPartitionList partList, + private static Statistics collectStatistics(HiveConf conf, PrunedPartitionList partList, Table table, List schema, List neededColumns) { - Statistics stats = new Statistics(); - boolean fetchColStats = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_STATS_FETCH_COLUMN_STATS); boolean fetchPartStats = HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_STATS_FETCH_PARTITION_STATS); + + return collectStatistics(conf, partList, table, schema, neededColumns, fetchColStats, fetchPartStats); + } + + public static Statistics collectStatistics(HiveConf conf, PrunedPartitionList partList, + Table table, List schema, List neededColumns, + boolean fetchColStats, boolean fetchPartStats) { + + Statistics stats = new Statistics(); + float deserFactor = HiveConf.getFloatVar(conf, HiveConf.ConfVars.HIVE_STATS_DESERIALIZATION_FACTOR);