hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [33/50] [abbrv] hive git commit: HIVE-15781: Druid CTAS should support DECIMAL type (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Date Thu, 02 Feb 2017 02:03:32 GMT
HIVE-15781: Druid CTAS should support DECIMAL type (Jesus Camacho Rodriguez, reviewed by Ashutosh
Chauhan)


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

Branch: refs/heads/hive-14535
Commit: 06b2b0e998183be6ed102ca57de1e00d39db3e95
Parents: 89664c0
Author: Jesus Camacho Rodriguez <jcamacho@apache.org>
Authored: Wed Feb 1 15:47:20 2017 +0000
Committer: Jesus Camacho Rodriguez <jcamacho@apache.org>
Committed: Wed Feb 1 18:49:47 2017 +0000

----------------------------------------------------------------------
 .../hadoop/hive/druid/io/DruidOutputFormat.java |  1 +
 .../hadoop/hive/druid/serde/DruidSerDe.java     |  5 ++++
 .../hadoop/hive/druid/TestDruidSerDe.java       | 24 ++++++++++++--------
 3 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/06b2b0e9/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
----------------------------------------------------------------------
diff --git a/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
b/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
index 86ddca8..12bbd73 100644
--- a/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
+++ b/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
@@ -140,6 +140,7 @@ public class DruidOutputFormat<K, V> implements HiveOutputFormat<K,
DruidWritabl
           break;
         case serdeConstants.FLOAT_TYPE_NAME:
         case serdeConstants.DOUBLE_TYPE_NAME:
+        case serdeConstants.DECIMAL_TYPE_NAME:
           af = new DoubleSumAggregatorFactory(columnNames.get(i), columnNames.get(i));
           break;
         default:

http://git-wip-us.apache.org/repos/asf/hive/blob/06b2b0e9/druid-handler/src/java/org/apache/hadoop/hive/druid/serde/DruidSerDe.java
----------------------------------------------------------------------
diff --git a/druid-handler/src/java/org/apache/hadoop/hive/druid/serde/DruidSerDe.java b/druid-handler/src/java/org/apache/hadoop/hive/druid/serde/DruidSerDe.java
index 9548d96..ea84326 100644
--- a/druid-handler/src/java/org/apache/hadoop/hive/druid/serde/DruidSerDe.java
+++ b/druid-handler/src/java/org/apache/hadoop/hive/druid/serde/DruidSerDe.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hive.serde2.objectinspector.StructObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.ByteObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.DoubleObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.FloatObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.HiveDecimalObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.LongObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
@@ -418,6 +419,10 @@ public class DruidSerDe extends AbstractSerDe {
           res = ((DoubleObjectInspector) fields.get(i).getFieldObjectInspector())
                   .get(values.get(i));
           break;
+        case DECIMAL:
+          res = ((HiveDecimalObjectInspector) fields.get(i).getFieldObjectInspector())
+                  .getPrimitiveJavaObject(values.get(i)).doubleValue();
+          break;
         case STRING:
           res = ((StringObjectInspector) fields.get(i).getFieldObjectInspector())
                   .getPrimitiveJavaObject(

http://git-wip-us.apache.org/repos/asf/hive/blob/06b2b0e9/druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidSerDe.java
----------------------------------------------------------------------
diff --git a/druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidSerDe.java b/druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidSerDe.java
index e6e3707..8dfa4d7 100644
--- a/druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidSerDe.java
+++ b/druid-handler/src/test/org/apache/hadoop/hive/druid/TestDruidSerDe.java
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
 import java.util.Properties;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.common.type.HiveDecimal;
 import org.apache.hadoop.hive.conf.Constants;
 import org.apache.hadoop.hive.druid.serde.DruidGroupByQueryRecordReader;
 import org.apache.hadoop.hive.druid.serde.DruidQueryRecordReader;
@@ -45,6 +46,7 @@ import org.apache.hadoop.hive.serde2.SerDeException;
 import org.apache.hadoop.hive.serde2.SerDeUtils;
 import org.apache.hadoop.hive.serde2.io.ByteWritable;
 import org.apache.hadoop.hive.serde2.io.DoubleWritable;
+import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
 import org.apache.hadoop.hive.serde2.io.ShortWritable;
 import org.apache.hadoop.hive.serde2.io.TimestampWritable;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -639,13 +641,14 @@ public class TestDruidSerDe {
   }
 
 
-  private static final String COLUMN_NAMES = "__time,c0,c1,c2,c3,c4,c5,c6";
-  private static final String COLUMN_TYPES = "timestamp,string,double,float,bigint,int,smallint,tinyint";
+  private static final String COLUMN_NAMES = "__time,c0,c1,c2,c3,c4,c5,c6,c7";
+  private static final String COLUMN_TYPES = "timestamp,string,double,float,decimal(38,18),bigint,int,smallint,tinyint";
   private static final Object[] ROW_OBJECT = new Object[] {
       new TimestampWritable(new Timestamp(1377907200000L)),
       new Text("dim1_val"),
-      new DoubleWritable(10669D),
-      new FloatWritable(10669F),
+      new DoubleWritable(10669.3D),
+      new FloatWritable(10669.45F),
+      new HiveDecimalWritable(HiveDecimal.create(1064.34D)),
       new LongWritable(1113939),
       new IntWritable(1112123),
       new ShortWritable((short) 12),
@@ -656,12 +659,13 @@ public class TestDruidSerDe {
       ImmutableMap.<String, Object>builder()
           .put("__time", 1377907200000L)
           .put("c0", "dim1_val")
-          .put("c1", 10669D)
-          .put("c2", 10669F)
-          .put("c3", 1113939L)
-          .put("c4", 1112123)
-          .put("c5", (short) 12)
-          .put("c6", (byte) 0)
+          .put("c1", 10669.3D)
+          .put("c2", 10669.45F)
+          .put("c3", 1064.34D)
+          .put("c4", 1113939L)
+          .put("c5", 1112123)
+          .put("c6", (short) 12)
+          .put("c7", (byte) 0)
           .put("__time_granularity", 1377907200000L)
           .build());
 


Mime
View raw message