hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject hive git commit: HIVE-13422 : Analyse command not working for column having datatype as decimal(38, 0) (Thomas Friedrich via Ashutosh Chauhan)
Date Mon, 25 Jul 2016 21:25:17 GMT
Repository: hive
Updated Branches:
  refs/heads/master 9f40c8fb9 -> 964b8a001


HIVE-13422 : Analyse command not working for column having datatype as decimal(38,0) (Thomas
Friedrich via Ashutosh Chauhan)

Signed-off-by: Ashutosh Chauhan <hashutosh@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/964b8a00
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/964b8a00
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/964b8a00

Branch: refs/heads/master
Commit: 964b8a00122ee3779858250b28fb70398ef83010
Parents: 9f40c8f
Author: Thomas Friedrich <tfriedr26@yahoo.com>
Authored: Mon Jul 25 14:24:06 2016 -0700
Committer: Ashutosh Chauhan <hashutosh@apache.org>
Committed: Mon Jul 25 14:24:06 2016 -0700

----------------------------------------------------------------------
 data/files/decimal.txt                          |  3 +-
 .../ql/udf/generic/GenericUDAFComputeStats.java | 32 +++++++++++++++++---
 .../clientpositive/compute_stats_decimal.q      |  2 +-
 .../clientpositive/compute_stats_decimal.q.out  |  8 ++---
 4 files changed, 34 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/964b8a00/data/files/decimal.txt
----------------------------------------------------------------------
diff --git a/data/files/decimal.txt b/data/files/decimal.txt
index 28800f5..5fc1139 100644
--- a/data/files/decimal.txt
+++ b/data/files/decimal.txt
@@ -15,4 +15,5 @@
 33.44
 55.3
 435.331
--0.342
\ No newline at end of file
+-0.342
+123456789012345678901234567890.123
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hive/blob/964b8a00/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
index b656263..ec80641 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDAFComputeStats.java
@@ -294,7 +294,7 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
     }
   }
 
-  public static abstract class GenericUDAFNumericStatsEvaluator<V, OI extends ObjectInspector>
+  public static abstract class GenericUDAFNumericStatsEvaluator<V, OI extends PrimitiveObjectInspector>
       extends GenericUDAFEvaluator {
 
     protected final static int MAX_BIT_VECTORS = 1024;
@@ -337,6 +337,8 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
     protected transient boolean warned;
 
     protected abstract OI getValueObjectInspector();
+    
+    protected abstract OI getValueObjectInspector(PrimitiveTypeInfo typeInfo);
 
     @Override
     public ObjectInspector init(Mode m, ObjectInspector[] parameters) throws HiveException
{
@@ -370,8 +372,8 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
         List<ObjectInspector> foi = new ArrayList<ObjectInspector>();
         foi.add(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
-        foi.add(getValueObjectInspector());
-        foi.add(getValueObjectInspector());
+        foi.add(getValueObjectInspector(inputOI.getTypeInfo()));
+        foi.add(getValueObjectInspector(inputOI.getTypeInfo()));
         foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
         foi.add(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
         foi.add(PrimitiveObjectInspectorFactory.writableIntObjectInspector);
@@ -395,8 +397,8 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       } else {
         List<ObjectInspector> foi = new ArrayList<ObjectInspector>();
         foi.add(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
-        foi.add(getValueObjectInspector());
-        foi.add(getValueObjectInspector());
+        foi.add(minFieldOI != null ? getValueObjectInspector(minFieldOI.getTypeInfo()) :
getValueObjectInspector());
+        foi.add(maxFieldOI != null ? getValueObjectInspector(maxFieldOI.getTypeInfo()) :
getValueObjectInspector());
         foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
         foi.add(PrimitiveObjectInspectorFactory.writableLongObjectInspector);
         foi.add(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
@@ -578,6 +580,11 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       return PrimitiveObjectInspectorFactory.javaLongObjectInspector;
     }
 
+    @Override
+    protected LongObjectInspector getValueObjectInspector(PrimitiveTypeInfo typeInfo) {
+      return getValueObjectInspector();
+    }
+
     @AggregationType(estimable = true)
     public class LongStatsAgg extends NumericStatsAgg {
       @Override
@@ -641,6 +648,11 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       return PrimitiveObjectInspectorFactory.javaDoubleObjectInspector;
     }
 
+    @Override
+    protected DoubleObjectInspector getValueObjectInspector(PrimitiveTypeInfo typeInfo) {
+      return getValueObjectInspector();
+    }
+
     @AggregationType(estimable = true)
     public class DoubleStatsAgg extends NumericStatsAgg {
       @Override
@@ -1282,6 +1294,11 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       return PrimitiveObjectInspectorFactory.javaHiveDecimalObjectInspector;
     }
 
+    @Override
+    protected HiveDecimalObjectInspector getValueObjectInspector(PrimitiveTypeInfo typeInfo)
{
+      return (JavaHiveDecimalObjectInspector)PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(typeInfo);
   	
+    }
+    
     @AggregationType(estimable = true)
     public class DecimalStatsAgg extends NumericStatsAgg {
       @Override
@@ -1347,6 +1364,11 @@ public class GenericUDAFComputeStats extends AbstractGenericUDAFResolver
{
       return PrimitiveObjectInspectorFactory.writableDateObjectInspector;
     }
 
+    @Override
+    protected DateObjectInspector getValueObjectInspector(PrimitiveTypeInfo typeInfo) {
+      return getValueObjectInspector();
+    }
+
     @AggregationType(estimable = true)
     public class DateStatsAgg extends NumericStatsAgg {
       @Override

http://git-wip-us.apache.org/repos/asf/hive/blob/964b8a00/ql/src/test/queries/clientpositive/compute_stats_decimal.q
----------------------------------------------------------------------
diff --git a/ql/src/test/queries/clientpositive/compute_stats_decimal.q b/ql/src/test/queries/clientpositive/compute_stats_decimal.q
index 77ec066..76e1468 100644
--- a/ql/src/test/queries/clientpositive/compute_stats_decimal.q
+++ b/ql/src/test/queries/clientpositive/compute_stats_decimal.q
@@ -1,6 +1,6 @@
 set hive.stats.autogather=true;
 
-create table tab_decimal(a decimal(10,3));
+create table tab_decimal(a decimal(35,3));
 
 -- insert some data
 LOAD DATA LOCAL INPATH "../../data/files/decimal.txt" INTO TABLE tab_decimal;

http://git-wip-us.apache.org/repos/asf/hive/blob/964b8a00/ql/src/test/results/clientpositive/compute_stats_decimal.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/compute_stats_decimal.q.out b/ql/src/test/results/clientpositive/compute_stats_decimal.q.out
index c204ab6..c1a2062 100644
--- a/ql/src/test/results/clientpositive/compute_stats_decimal.q.out
+++ b/ql/src/test/results/clientpositive/compute_stats_decimal.q.out
@@ -1,8 +1,8 @@
-PREHOOK: query: create table tab_decimal(a decimal(10,3))
+PREHOOK: query: create table tab_decimal(a decimal(35,3))
 PREHOOK: type: CREATETABLE
 PREHOOK: Output: database:default
 PREHOOK: Output: default@tab_decimal
-POSTHOOK: query: create table tab_decimal(a decimal(10,3))
+POSTHOOK: query: create table tab_decimal(a decimal(35,3))
 POSTHOOK: type: CREATETABLE
 POSTHOOK: Output: database:default
 POSTHOOK: Output: default@tab_decimal
@@ -24,7 +24,7 @@ POSTHOOK: query: select count(*) from tab_decimal
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@tab_decimal
 #### A masked pattern was here ####
-18
+19
 PREHOOK: query: -- compute statistical summary of data
 select compute_stats(a, 18) from tab_decimal
 PREHOOK: type: QUERY
@@ -35,4 +35,4 @@ select compute_stats(a, 18) from tab_decimal
 POSTHOOK: type: QUERY
 POSTHOOK: Input: default@tab_decimal
 #### A masked pattern was here ####
-{"columntype":"Decimal","min":-87.2,"max":435.331,"countnulls":2,"numdistinctvalues":13,"ndvbitvector":"{0,
1, 2, 3, 4}{0, 1, 2, 3, 5}{0, 1, 2, 3}{0, 1, 2}{0, 1, 2}{0, 1, 2, 3, 5}{0, 1, 3}{0, 1, 2,
4}{0, 1, 2, 3, 5}{0, 1, 2, 3}{0, 1, 2}{0, 1}{0, 1, 2}{0, 1, 2, 3}{0, 1, 2, 6, 8}{0, 1, 2,
3}{0, 1, 2}{0, 1, 4, 5}"}
+{"columntype":"Decimal","min":-87.2,"max":123456789012345678901234567890.123,"countnulls":2,"numdistinctvalues":13,"ndvbitvector":"{0,
1, 2, 3, 4}{0, 1, 2, 3, 5}{0, 1, 2, 3}{0, 1, 2}{0, 1, 2}{0, 1, 2, 3, 5}{0, 1, 3}{0, 1, 2,
4}{0, 1, 2, 3, 5}{0, 1, 2, 3}{0, 1, 2}{0, 1}{0, 1, 2}{0, 1, 2, 3}{0, 1, 2, 6, 8}{0, 1, 2,
3}{0, 1, 2}{0, 1, 4, 5}"}


Mime
View raw message