hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1419202 - in /hive/trunk: ql/src/test/queries/clientpositive/null_cast.q ql/src/test/results/clientpositive/null_cast.q.out serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
Date Mon, 10 Dec 2012 05:41:31 GMT
Author: hashutosh
Date: Mon Dec 10 05:41:31 2012
New Revision: 1419202

URL: http://svn.apache.org/viewvc?rev=1419202&view=rev
Log:
HIVE-2689 : ObjectInspectorConverters cannot convert Void types to Array/Map/Struct types.
(Jonathan Chang via Ashutosh Chauhan)

Added:
    hive/trunk/ql/src/test/queries/clientpositive/null_cast.q
    hive/trunk/ql/src/test/results/clientpositive/null_cast.q.out
Modified:
    hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java

Added: hive/trunk/ql/src/test/queries/clientpositive/null_cast.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/null_cast.q?rev=1419202&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/null_cast.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/null_cast.q Mon Dec 10 05:41:31 2012
@@ -0,0 +1,11 @@
+EXPLAIN SELECT ARRAY(NULL, 0), 
+               ARRAY(NULL, ARRAY()),
+               ARRAY(NULL, MAP()),
+               ARRAY(NULL, STRUCT(0))
+        FROM src LIMIT 1;
+
+SELECT ARRAY(NULL, 0), 
+       ARRAY(NULL, ARRAY()),
+       ARRAY(NULL, MAP()),
+       ARRAY(NULL, STRUCT(0))
+FROM src LIMIT 1;

Added: hive/trunk/ql/src/test/results/clientpositive/null_cast.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/null_cast.q.out?rev=1419202&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/null_cast.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/null_cast.q.out Mon Dec 10 05:41:31 2012
@@ -0,0 +1,67 @@
+PREHOOK: query: EXPLAIN SELECT ARRAY(NULL, 0), 
+               ARRAY(NULL, ARRAY()),
+               ARRAY(NULL, MAP()),
+               ARRAY(NULL, STRUCT(0))
+        FROM src LIMIT 1
+PREHOOK: type: QUERY
+POSTHOOK: query: EXPLAIN SELECT ARRAY(NULL, 0), 
+               ARRAY(NULL, ARRAY()),
+               ARRAY(NULL, MAP()),
+               ARRAY(NULL, STRUCT(0))
+        FROM src LIMIT 1
+POSTHOOK: type: QUERY
+ABSTRACT SYNTAX TREE:
+  (TOK_QUERY (TOK_FROM (TOK_TABREF (TOK_TABNAME src))) (TOK_INSERT (TOK_DESTINATION (TOK_DIR
TOK_TMP_FILE)) (TOK_SELECT (TOK_SELEXPR (TOK_FUNCTION ARRAY TOK_NULL 0)) (TOK_SELEXPR (TOK_FUNCTION
ARRAY TOK_NULL (TOK_FUNCTION ARRAY))) (TOK_SELEXPR (TOK_FUNCTION ARRAY TOK_NULL (TOK_FUNCTION
MAP))) (TOK_SELEXPR (TOK_FUNCTION ARRAY TOK_NULL (TOK_FUNCTION STRUCT 0)))) (TOK_LIMIT 1)))
+
+STAGE DEPENDENCIES:
+  Stage-1 is a root stage
+  Stage-0 is a root stage
+
+STAGE PLANS:
+  Stage: Stage-1
+    Map Reduce
+      Alias -> Map Operator Tree:
+        src 
+          TableScan
+            alias: src
+            Select Operator
+              expressions:
+                    expr: array(null,0)
+                    type: array<int>
+                    expr: array(null,array())
+                    type: array<array<string>>
+                    expr: array(null,map())
+                    type: array<map<string,string>>
+                    expr: array(null,struct(0))
+                    type: array<struct<col1:int>>
+              outputColumnNames: _col0, _col1, _col2, _col3
+              Limit
+                File Output Operator
+                  compressed: false
+                  GlobalTableId: 0
+                  table:
+                      input format: org.apache.hadoop.mapred.TextInputFormat
+                      output format: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat
+
+  Stage: Stage-0
+    Fetch Operator
+      limit: 1
+
+
+PREHOOK: query: SELECT ARRAY(NULL, 0), 
+       ARRAY(NULL, ARRAY()),
+       ARRAY(NULL, MAP()),
+       ARRAY(NULL, STRUCT(0))
+FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT ARRAY(NULL, 0), 
+       ARRAY(NULL, ARRAY()),
+       ARRAY(NULL, MAP()),
+       ARRAY(NULL, STRUCT(0))
+FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+[null,0]	[null,[]]	[null,{}]	[null,{"col1":0}]

Modified: hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java?rev=1419202&r1=1419201&r2=1419202&view=diff
==============================================================================
--- hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
(original)
+++ hive/trunk/serde/src/java/org/apache/hadoop/hive/serde2/objectinspector/ObjectInspectorConverters.java
Mon Dec 10 05:41:31 2012
@@ -34,6 +34,7 @@ import org.apache.hadoop.hive.serde2.obj
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableShortObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.SettableTimestampObjectInspector;
 import org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableStringObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.VoidObjectInspector;
 
 /**
  * ObjectInspectorConverters.
@@ -124,13 +125,13 @@ public final class ObjectInspectorConver
             + " not supported yet.");
       }
     case STRUCT:
-      return new StructConverter((StructObjectInspector) inputOI,
+      return new StructConverter(inputOI,
           (SettableStructObjectInspector) outputOI);
     case LIST:
-      return new ListConverter((ListObjectInspector) inputOI,
+      return new ListConverter(inputOI,
           (SettableListObjectInspector) outputOI);
     case MAP:
-      return new MapConverter((MapObjectInspector) inputOI,
+      return new MapConverter(inputOI,
           (SettableMapObjectInspector) outputOI);
     default:
       throw new RuntimeException("Hive internal error: conversion of "
@@ -154,14 +155,20 @@ public final class ObjectInspectorConver
 
     Object output;
 
-    public ListConverter(ListObjectInspector inputOI,
+    public ListConverter(ObjectInspector inputOI,
         SettableListObjectInspector outputOI) {
-      this.inputOI = inputOI;
-      this.outputOI = outputOI;
-      inputElementOI = inputOI.getListElementObjectInspector();
-      outputElementOI = outputOI.getListElementObjectInspector();
-      output = outputOI.create(0);
-      elementConverters = new ArrayList<Converter>();
+      if (inputOI instanceof ListObjectInspector) {
+        this.inputOI = (ListObjectInspector)inputOI;
+        this.outputOI = outputOI;
+        inputElementOI = this.inputOI.getListElementObjectInspector();
+        outputElementOI = outputOI.getListElementObjectInspector();
+        output = outputOI.create(0);
+        elementConverters = new ArrayList<Converter>();
+      } else if (!(inputOI instanceof VoidObjectInspector)) {
+        throw new RuntimeException("Hive internal error: conversion of " +
+            inputOI.getTypeName() + " to " + outputOI.getTypeName() +
+            "not supported yet.");
+      }
     }
 
     @Override
@@ -207,22 +214,27 @@ public final class ObjectInspectorConver
 
     Object output;
 
-    public StructConverter(StructObjectInspector inputOI,
+    public StructConverter(ObjectInspector inputOI,
         SettableStructObjectInspector outputOI) {
-
-      this.inputOI = inputOI;
-      this.outputOI = outputOI;
-      inputFields = inputOI.getAllStructFieldRefs();
-      outputFields = outputOI.getAllStructFieldRefs();
-      assert (inputFields.size() == outputFields.size());
-
-      fieldConverters = new ArrayList<Converter>(inputFields.size());
-      for (int f = 0; f < inputFields.size(); f++) {
-        fieldConverters.add(getConverter(inputFields.get(f)
-            .getFieldObjectInspector(), outputFields.get(f)
-            .getFieldObjectInspector()));
+      if (inputOI instanceof StructObjectInspector) {
+        this.inputOI = (StructObjectInspector)inputOI;
+        this.outputOI = outputOI;
+        inputFields = this.inputOI.getAllStructFieldRefs();
+        outputFields = outputOI.getAllStructFieldRefs();
+        assert (inputFields.size() == outputFields.size());
+
+        fieldConverters = new ArrayList<Converter>(inputFields.size());
+        for (int f = 0; f < inputFields.size(); f++) {
+          fieldConverters.add(getConverter(inputFields.get(f)
+              .getFieldObjectInspector(), outputFields.get(f)
+              .getFieldObjectInspector()));
+        }
+        output = outputOI.create();
+      } else if (!(inputOI instanceof VoidObjectInspector)) {
+        throw new RuntimeException("Hive internal error: conversion of " +
+            inputOI.getTypeName() + " to " + outputOI.getTypeName() +
+            "not supported yet.");
       }
-      output = outputOI.create();
     }
 
     @Override
@@ -263,17 +275,23 @@ public final class ObjectInspectorConver
 
     Object output;
 
-    public MapConverter(MapObjectInspector inputOI,
+    public MapConverter(ObjectInspector inputOI,
         SettableMapObjectInspector outputOI) {
-      this.inputOI = inputOI;
-      this.outputOI = outputOI;
-      inputKeyOI = inputOI.getMapKeyObjectInspector();
-      outputKeyOI = outputOI.getMapKeyObjectInspector();
-      inputValueOI = inputOI.getMapValueObjectInspector();
-      outputValueOI = outputOI.getMapValueObjectInspector();
-      keyConverters = new ArrayList<Converter>();
-      valueConverters = new ArrayList<Converter>();
-      output = outputOI.create();
+      if (inputOI instanceof MapObjectInspector) {
+        this.inputOI = (MapObjectInspector)inputOI;
+        this.outputOI = outputOI;
+        inputKeyOI = this.inputOI.getMapKeyObjectInspector();
+        outputKeyOI = outputOI.getMapKeyObjectInspector();
+        inputValueOI = this.inputOI.getMapValueObjectInspector();
+        outputValueOI = outputOI.getMapValueObjectInspector();
+        keyConverters = new ArrayList<Converter>();
+        valueConverters = new ArrayList<Converter>();
+        output = outputOI.create();
+      } else if (!(inputOI instanceof VoidObjectInspector)) {
+        throw new RuntimeException("Hive internal error: conversion of " +
+            inputOI.getTypeName() + " to " + outputOI.getTypeName() +
+            "not supported yet.");
+      }
     }
 
     @Override



Mime
View raw message