You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by rb...@apache.org on 2019/10/03 00:27:30 UTC

[hive] branch master updated: HIVE-22246: Beeline reflector should handle map types (Rajesh Balamohan, reviewed by Gopal V)

This is an automated email from the ASF dual-hosted git repository.

rbalamohan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new e9b974a  HIVE-22246: Beeline reflector should handle map types (Rajesh Balamohan, reviewed by Gopal V)
e9b974a is described below

commit e9b974a230bce84fa77e135a9efbb6351c1e8687
Author: Rajesh Balamohan <rb...@apache.org>
AuthorDate: Thu Oct 3 05:57:12 2019 +0530

    HIVE-22246: Beeline reflector should handle map types (Rajesh Balamohan, reviewed by Gopal V)
---
 beeline/src/java/org/apache/hive/beeline/Reflector.java | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/beeline/src/java/org/apache/hive/beeline/Reflector.java b/beeline/src/java/org/apache/hive/beeline/Reflector.java
index 1434d94..e4e0b1a 100644
--- a/beeline/src/java/org/apache/hive/beeline/Reflector.java
+++ b/beeline/src/java/org/apache/hive/beeline/Reflector.java
@@ -26,9 +26,11 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 class Reflector {
   private final BeeLine beeLine;
@@ -107,6 +109,16 @@ class Reflector {
     }
     if (toType == String.class) {
       return new String(ob.toString());
+    } else if (toType == Map.class) {
+      String[] vars = ob.toString().split(",");
+      Map<String, String> keyValMap = new HashMap<>();
+      for (String keyValStr : vars) {
+        String[] keyVal = keyValStr.trim().split("=", 2);
+        if (keyVal.length == 2) {
+          keyValMap.put(keyVal[0], keyVal[1]);
+        }
+      }
+      return keyValMap;
     } else if (toType == Byte.class || toType == byte.class) {
       return Byte.valueOf(ob.toString());
     } else if (toType == Character.class || toType == char.class) {