Index: hbase-handler/src/test/results/positive/hbase_stats_empty_partition.q.out =================================================================== --- hbase-handler/src/test/results/positive/hbase_stats_empty_partition.q.out (revision 0) +++ hbase-handler/src/test/results/positive/hbase_stats_empty_partition.q.out (revision 0) @@ -0,0 +1,61 @@ +PREHOOK: query: -- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string) +PREHOOK: type: CREATETABLE +POSTHOOK: query: -- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@tmptable +PREHOOK: query: insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value' +PREHOOK: type: QUERY +PREHOOK: Input: default@src +PREHOOK: Output: default@tmptable@part=1 +POSTHOOK: query: insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +POSTHOOK: Output: default@tmptable@part=1 +POSTHOOK: Lineage: tmptable PARTITION(part=1).key SIMPLE [(src)src.FieldSchema(name:key, type:string, comment:default), ] +POSTHOOK: Lineage: tmptable PARTITION(part=1).value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ] +PREHOOK: query: describe formatted tmptable partition (part = '1') +PREHOOK: type: DESCTABLE +POSTHOOK: query: describe formatted tmptable partition (part = '1') +POSTHOOK: type: DESCTABLE +POSTHOOK: Lineage: tmptable PARTITION(part=1).key SIMPLE [(src)src.FieldSchema(name:key, type:string, comment:default), ] +POSTHOOK: Lineage: tmptable PARTITION(part=1).value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ] +# col_name data_type comment + +key string None +value string None + +# Partition Information +# col_name data_type comment + +part string None + +# Detailed Partition Information +Partition Value: [1] +Database: default +Table: tmptable +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + numFiles 1 + numRows 0 + rawDataSize 0 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 Index: hbase-handler/src/test/queries/positive/hbase_stats_empty_partition.q =================================================================== --- hbase-handler/src/test/queries/positive/hbase_stats_empty_partition.q (revision 0) +++ hbase-handler/src/test/queries/positive/hbase_stats_empty_partition.q (revision 0) @@ -0,0 +1,13 @@ +-- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string); + +set hive.stats.autogather=true; +set hive.stats.reliable=true; + +set hive.stats.dbclass=hbase; + +insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value'; + +describe formatted tmptable partition (part = '1'); Index: hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStatsPublisher.java =================================================================== --- hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStatsPublisher.java (revision 1374461) +++ hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseStatsPublisher.java (working copy) @@ -68,6 +68,11 @@ // Write in HBase + if (stats.isEmpty()) { + // If there are no stats to publish, nothing to do. + return true; + } + if (!HBaseStatsUtils.isValidStatisticSet(stats.keySet())) { LOG.warn("Warning. Invalid statistic: " + stats.keySet().toString() + ", supported stats: " Index: ql/src/test/results/clientpositive/stats_empty_partition.q.out =================================================================== --- ql/src/test/results/clientpositive/stats_empty_partition.q.out (revision 0) +++ ql/src/test/results/clientpositive/stats_empty_partition.q.out (revision 0) @@ -0,0 +1,61 @@ +PREHOOK: query: -- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string) +PREHOOK: type: CREATETABLE +POSTHOOK: query: -- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string) +POSTHOOK: type: CREATETABLE +POSTHOOK: Output: default@tmptable +PREHOOK: query: insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value' +PREHOOK: type: QUERY +PREHOOK: Input: default@src +PREHOOK: Output: default@tmptable@part=1 +POSTHOOK: query: insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value' +POSTHOOK: type: QUERY +POSTHOOK: Input: default@src +POSTHOOK: Output: default@tmptable@part=1 +POSTHOOK: Lineage: tmptable PARTITION(part=1).key SIMPLE [(src)src.FieldSchema(name:key, type:string, comment:default), ] +POSTHOOK: Lineage: tmptable PARTITION(part=1).value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ] +PREHOOK: query: describe formatted tmptable partition (part = '1') +PREHOOK: type: DESCTABLE +POSTHOOK: query: describe formatted tmptable partition (part = '1') +POSTHOOK: type: DESCTABLE +POSTHOOK: Lineage: tmptable PARTITION(part=1).key SIMPLE [(src)src.FieldSchema(name:key, type:string, comment:default), ] +POSTHOOK: Lineage: tmptable PARTITION(part=1).value SIMPLE [(src)src.FieldSchema(name:value, type:string, comment:default), ] +# col_name data_type comment + +key string None +value string None + +# Partition Information +# col_name data_type comment + +part string None + +# Detailed Partition Information +Partition Value: [1] +Database: default +Table: tmptable +#### A masked pattern was here #### +Protect Mode: None +#### A masked pattern was here #### +Partition Parameters: + numFiles 1 + numRows 0 + rawDataSize 0 + totalSize 0 +#### A masked pattern was here #### + +# Storage Information +SerDe Library: org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe +InputFormat: org.apache.hadoop.mapred.TextInputFormat +OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat +Compressed: No +Num Buckets: -1 +Bucket Columns: [] +Sort Columns: [] +Storage Desc Params: + serialization.format 1 Index: ql/src/test/queries/clientpositive/stats_empty_partition.q =================================================================== --- ql/src/test/queries/clientpositive/stats_empty_partition.q (revision 0) +++ ql/src/test/queries/clientpositive/stats_empty_partition.q (revision 0) @@ -0,0 +1,11 @@ +-- This test verifies that writing an empty partition succeeds when +-- hive.stats.reliable is set to true. + +create table tmptable(key string, value string) partitioned by (part string); + +set hive.stats.autogather=true; +set hive.stats.reliable=true; + +insert overwrite table tmptable partition (part = '1') select * from src where key = 'no_such_value'; + +describe formatted tmptable partition (part = '1'); Index: ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java =================================================================== --- ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java (revision 1374461) +++ ql/src/java/org/apache/hadoop/hive/ql/stats/jdbc/JDBCStatsPublisher.java (working copy) @@ -119,6 +119,11 @@ @Override public boolean publishStat(String fileID, Map stats) { + if (stats.isEmpty()) { + // If there are no stats to publish, nothing to do. + return true; + } + if (conn == null) { LOG.error("JDBC connection is null. Cannot publish stats without JDBC connection."); return false;