You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/04/03 16:42:19 UTC
svn commit: r1464049 - in /hive/trunk:
jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Author: hashutosh
Date: Wed Apr 3 14:42:19 2013
New Revision: 1464049
URL: http://svn.apache.org/r1464049
Log:
HIVE-4252 : hiveserver2 string representation of complex types are inconsistent with cli (Thejas Nair via Ashutosh Chauhan)
Modified:
hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Modified: hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1464049&r1=1464048&r2=1464049&view=diff
==============================================================================
--- hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/trunk/jdbc/src/test/org/apache/hive/jdbc/TestJdbcDriver2.java Wed Apr 3 14:42:19 2013
@@ -422,14 +422,14 @@ public class TestJdbcDriver2 extends Tes
assertEquals("[]", res.getString(5));
assertEquals("{}", res.getString(6));
assertEquals("{}", res.getString(7));
- assertEquals("[null, null, null]", res.getString(8));
+ assertEquals("{\"r\":null,\"s\":null,\"t\":null}", res.getString(8));
assertEquals(-1, res.getByte(9));
assertEquals(-1, res.getShort(10));
assertEquals(-1.0f, res.getFloat(11));
assertEquals(-1, res.getLong(12));
assertEquals("[]", res.getString(13));
assertEquals("{}", res.getString(14));
- assertEquals("[null, null]", res.getString(15));
+ assertEquals("{\"r\":null,\"s\":null}", res.getString(15));
assertEquals("[]", res.getString(16));
assertEquals(null, res.getString(17));
assertEquals(null, res.getTimestamp(17));
@@ -442,18 +442,18 @@ public class TestJdbcDriver2 extends Tes
assertEquals(true, res.getBoolean(2));
assertEquals(1.1d, res.getDouble(3));
assertEquals("1", res.getString(4));
- assertEquals("[1, 2]", res.getString(5));
- assertEquals("{1=x, 2=y}", res.getString(6));
- assertEquals("{k=v}", res.getString(7));
- assertEquals("[a, 9, 2.2]", res.getString(8));
+ assertEquals("[1,2]", res.getString(5));
+ assertEquals("{1:\"x\",2:\"y\"}", res.getString(6));
+ assertEquals("{\"k\":\"v\"}", res.getString(7));
+ assertEquals("{\"r\":\"a\",\"s\":9,\"t\":2.2}", res.getString(8));
assertEquals(1, res.getByte(9));
assertEquals(1, res.getShort(10));
assertEquals(1.0f, res.getFloat(11));
assertEquals(1, res.getLong(12));
- assertEquals("[[a, b], [c, d]]", res.getString(13));
- assertEquals("{1={11=12, 13=14}, 2={21=22}}", res.getString(14));
- assertEquals("[1, [2, x]]", res.getString(15));
- assertEquals("[[{}, 1], [{c=d, a=b}, 2]]", res.getString(16));
+ assertEquals("[[\"a\",\"b\"],[\"c\",\"d\"]]", res.getString(13));
+ assertEquals("{1:{11:12,13:14},2:{21:22}}", res.getString(14));
+ assertEquals("{\"r\":1,\"s\":{\"a\":2,\"b\":\"x\"}}", res.getString(15));
+ assertEquals("[{\"m\":{},\"n\":1},{\"m\":{\"a\":\"b\",\"c\":\"d\"},\"n\":2}]", res.getString(16));
assertEquals("2012-04-22 09:00:00.123456789", res.getString(17));
assertEquals("2012-04-22 09:00:00.123456789", res.getTimestamp(17).toString());
assertEquals("123456789.0123456", res.getBigDecimal(18).toString());
Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java?rev=1464049&r1=1464048&r2=1464049&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java Wed Apr 3 14:42:19 2013
@@ -35,6 +35,7 @@ import org.apache.hadoop.hive.ql.process
import org.apache.hadoop.hive.ql.session.SessionState;
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.serde2.SerDe;
+import org.apache.hadoop.hive.serde2.SerDeUtils;
import org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
@@ -199,7 +200,7 @@ public class SQLOperation extends Execut
Object obj = ObjectInspectorUtils.copyToStandardObject(o, oi, ObjectInspectorCopyOption.JAVA);
if (obj == null) {
- return obj;
+ return null;
}
if(oi.getTypeName().equals(serdeConstants.BINARY_TYPE_NAME)) {
return new String((byte[])obj);
@@ -207,9 +208,8 @@ public class SQLOperation extends Execut
// for now, expose non-primitive as a string
// TODO: expose non-primitive as a structured object while maintaining JDBC compliance
if (oi.getCategory() != ObjectInspector.Category.PRIMITIVE) {
- return obj.toString();
+ return SerDeUtils.getJSONString(o, oi);
}
-
return obj;
}