hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1611234 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java test/queries/clientpositive/colstats_all_nulls.q test/results/clientpositive/colstats_all_nulls.q.out
Date Thu, 17 Jul 2014 01:40:12 GMT
Author: hashutosh
Date: Thu Jul 17 01:40:12 2014
New Revision: 1611234

URL: http://svn.apache.org/r1611234
Log:
HIVE-7412 : column stats collection throws exception if all values for a column is null (Ashutosh
Chauhan via Gunther Hagleitner, Navis)

Added:
    hive/trunk/ql/src/test/queries/clientpositive/colstats_all_nulls.q
    hive/trunk/ql/src/test/results/clientpositive/colstats_all_nulls.q.out
Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java?rev=1611234&r1=1611233&r2=1611234&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
(original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
Thu Jul 17 01:40:12 2014
@@ -594,14 +594,14 @@ public class GenericUDAFComputeStats ext
 
       @Override
       protected void updateMin(Object minValue, LongObjectInspector minFieldOI) {
-        if (min == null || (minValue != null && min > minFieldOI.get(minValue)))
{
+        if ((minValue != null) && (min == null || (min > minFieldOI.get(minValue))))
{
           min = minFieldOI.get(minValue);
         }
       }
 
       @Override
       protected void updateMax(Object maxValue, LongObjectInspector maxFieldOI) {
-        if (max == null || (maxValue != null && max < maxFieldOI.get(maxValue)))
{
+        if ((maxValue != null ) && (max == null || (max < maxFieldOI.get(maxValue))))
{
           max = maxFieldOI.get(maxValue);
         }
       }
@@ -657,14 +657,14 @@ public class GenericUDAFComputeStats ext
 
       @Override
       protected void updateMin(Object minValue, DoubleObjectInspector minFieldOI) {
-        if (min == null || (minValue != null && min > minFieldOI.get(minValue)))
{
+        if ((minValue != null) && (min == null || (min > minFieldOI.get(minValue))))
{
           min = minFieldOI.get(minValue);
         }
       }
 
       @Override
       protected void updateMax(Object maxValue, DoubleObjectInspector maxFieldOI) {
-        if (max == null || (maxValue != null && max < maxFieldOI.get(maxValue)))
{
+        if ((maxValue != null ) && (max == null || (max < maxFieldOI.get(maxValue))))
{
           max = maxFieldOI.get(maxValue);
         }
       }
@@ -995,7 +995,7 @@ public class GenericUDAFComputeStats ext
       }
 
       if (total != 0) {
-         avgLength = (double)(myagg.sumLength / (1.0 * total));
+         avgLength = myagg.sumLength / (1.0 * total);
       }
 
       // Serialize the result struct
@@ -1241,7 +1241,7 @@ public class GenericUDAFComputeStats ext
       long count = myagg.count + myagg.countNulls;
 
       if (count != 0) {
-        avgLength = (double)(myagg.sumLength / (1.0 * (myagg.count + myagg.countNulls)));
+        avgLength = myagg.sumLength / (1.0 * (myagg.count + myagg.countNulls));
       }
 
       // Serialize the result struct
@@ -1287,7 +1287,7 @@ public class GenericUDAFComputeStats ext
 
       @Override
       protected void updateMin(Object minValue, HiveDecimalObjectInspector minFieldOI) {
-        if (min == null || (minValue != null &&
+        if ((minValue != null) && (min == null ||
             min.compareTo(minFieldOI.getPrimitiveJavaObject(minValue)) > 0)) {
           min = minFieldOI.getPrimitiveJavaObject(minValue);
         }
@@ -1295,7 +1295,7 @@ public class GenericUDAFComputeStats ext
 
       @Override
       protected void updateMax(Object maxValue, HiveDecimalObjectInspector maxFieldOI) {
-        if (max == null || (maxValue != null &&
+        if ((maxValue != null) && (max == null ||
             max.compareTo(maxFieldOI.getPrimitiveJavaObject(maxValue)) < 0)) {
           max = maxFieldOI.getPrimitiveJavaObject(maxValue);
         }

Added: hive/trunk/ql/src/test/queries/clientpositive/colstats_all_nulls.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/colstats_all_nulls.q?rev=1611234&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/colstats_all_nulls.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/colstats_all_nulls.q Thu Jul 17 01:40:12
2014
@@ -0,0 +1,11 @@
+CREATE TABLE src_null(a bigint) STORED AS TEXTFILE;
+LOAD DATA LOCAL INPATH '../../data/files/nulls.txt' INTO TABLE src_null;
+
+create table all_nulls as SELECT a, cast(a as double) as b, cast(a as decimal) as c  FROM
src_null where a is null limit 5;
+analyze table all_nulls compute statistics for columns;
+
+describe formatted all_nulls.a;
+describe formatted all_nulls.b;
+
+drop table all_nulls;
+drop table src_null;

Added: hive/trunk/ql/src/test/results/clientpositive/colstats_all_nulls.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/colstats_all_nulls.q.out?rev=1611234&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/colstats_all_nulls.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/colstats_all_nulls.q.out Thu Jul 17 01:40:12
2014
@@ -0,0 +1,64 @@
+PREHOOK: query: CREATE TABLE src_null(a bigint) STORED AS TEXTFILE
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+POSTHOOK: query: CREATE TABLE src_null(a bigint) STORED AS TEXTFILE
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@src_null
+PREHOOK: query: LOAD DATA LOCAL INPATH '../../data/files/nulls.txt' INTO TABLE src_null
+PREHOOK: type: LOAD
+#### A masked pattern was here ####
+PREHOOK: Output: default@src_null
+POSTHOOK: query: LOAD DATA LOCAL INPATH '../../data/files/nulls.txt' INTO TABLE src_null
+POSTHOOK: type: LOAD
+#### A masked pattern was here ####
+POSTHOOK: Output: default@src_null
+PREHOOK: query: create table all_nulls as SELECT a, cast(a as double) as b, cast(a as decimal)
as c  FROM src_null where a is null limit 5
+PREHOOK: type: CREATETABLE_AS_SELECT
+PREHOOK: Input: default@src_null
+POSTHOOK: query: create table all_nulls as SELECT a, cast(a as double) as b, cast(a as decimal)
as c  FROM src_null where a is null limit 5
+POSTHOOK: type: CREATETABLE_AS_SELECT
+POSTHOOK: Input: default@src_null
+POSTHOOK: Output: default@all_nulls
+PREHOOK: query: analyze table all_nulls compute statistics for columns
+PREHOOK: type: QUERY
+PREHOOK: Input: default@all_nulls
+#### A masked pattern was here ####
+POSTHOOK: query: analyze table all_nulls compute statistics for columns
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@all_nulls
+#### A masked pattern was here ####
+PREHOOK: query: describe formatted all_nulls.a
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@all_nulls
+POSTHOOK: query: describe formatted all_nulls.a
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@all_nulls
+# col_name            	data_type           	min                 	max                 	num_nulls
          	distinct_count      	avg_col_len         	max_col_len         	num_trues      
    	num_falses          	comment             
+	 	 	 	 	 	 	 	 	 	 
+a                   	bigint              	0                   	0                   	5   
               	1                   	                    	                    	          
         	                    	from deserializer   
+PREHOOK: query: describe formatted all_nulls.b
+PREHOOK: type: DESCTABLE
+PREHOOK: Input: default@all_nulls
+POSTHOOK: query: describe formatted all_nulls.b
+POSTHOOK: type: DESCTABLE
+POSTHOOK: Input: default@all_nulls
+# col_name            	data_type           	min                 	max                 	num_nulls
          	distinct_count      	avg_col_len         	max_col_len         	num_trues      
    	num_falses          	comment             
+	 	 	 	 	 	 	 	 	 	 
+b                   	double              	0.0                 	0.0                 	5   
               	1                   	                    	                    	          
         	                    	from deserializer   
+PREHOOK: query: drop table all_nulls
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@all_nulls
+PREHOOK: Output: default@all_nulls
+POSTHOOK: query: drop table all_nulls
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@all_nulls
+POSTHOOK: Output: default@all_nulls
+PREHOOK: query: drop table src_null
+PREHOOK: type: DROPTABLE
+PREHOOK: Input: default@src_null
+PREHOOK: Output: default@src_null
+POSTHOOK: query: drop table src_null
+POSTHOOK: type: DROPTABLE
+POSTHOOK: Input: default@src_null
+POSTHOOK: Output: default@src_null



Mime
View raw message