hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From the...@apache.org
Subject svn commit: r1584146 - in /hive/branches/branch-0.13: data/files/non_ascii_tbl.txt itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Date Wed, 02 Apr 2014 19:46:58 GMT
Author: thejas
Date: Wed Apr  2 19:46:57 2014
New Revision: 1584146

URL: http://svn.apache.org/r1584146
Log:
HIVE-6068 : HiveServer2 client on windows does not handle the non-ascii characters properly
(Vaibhav Gumashta via Thejas Nair)

Added:
    hive/branches/branch-0.13/data/files/non_ascii_tbl.txt
Modified:
    hive/branches/branch-0.13/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
    hive/branches/branch-0.13/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java

Added: hive/branches/branch-0.13/data/files/non_ascii_tbl.txt
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/data/files/non_ascii_tbl.txt?rev=1584146&view=auto
==============================================================================
--- hive/branches/branch-0.13/data/files/non_ascii_tbl.txt (added)
+++ hive/branches/branch-0.13/data/files/non_ascii_tbl.txt Wed Apr  2 19:46:57 2014
@@ -0,0 +1 @@
+1|Garçu Kôkaku kidôtai

Modified: hive/branches/branch-0.13/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1584146&r1=1584145&r2=1584146&view=diff
==============================================================================
--- hive/branches/branch-0.13/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
(original)
+++ hive/branches/branch-0.13/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
Wed Apr  2 19:46:57 2014
@@ -82,6 +82,7 @@ public class TestJdbcDriver2 {
   private static final String dataTypeTableName = "testdatatypetable";
   private static final String dataTypeTableComment = "Table with many column data types";
   private final HiveConf conf;
+  public static String dataFileDir;
   private final Path dataFilePath;
   private final Path dataTypeDataFilePath;
   private Connection con;
@@ -90,7 +91,7 @@ public class TestJdbcDriver2 {
 
   public TestJdbcDriver2() {
     conf = new HiveConf(TestJdbcDriver2.class);
-    String dataFileDir = conf.get("test.data.files").replace('\\', '/')
+    dataFileDir = conf.get("test.data.files").replace('\\', '/')
         .replace("c:", "");
     dataFilePath = new Path(dataFileDir, "kv1.txt");
     dataTypeDataFilePath = new Path(dataFileDir, "datatypes.txt");
@@ -2071,4 +2072,40 @@ public class TestJdbcDriver2 {
       return value;
     }
   }
+
+  /**
+   * Loads data from a table containing non-ascii value column
+   * Runs a query and compares the return value
+   * @throws Exception
+   */
+  @Test
+  public void testNonAsciiReturnValues() throws Exception {
+    String nonAsciiTableName = "nonAsciiTable";
+    String nonAsciiString = "Garçu Kôkaku kidôtai";
+    Path nonAsciiFilePath = new Path(dataFileDir, "non_ascii_tbl.txt");
+    Statement stmt = con.createStatement();
+    stmt.execute("set hive.support.concurrency = false");
+
+    // Create table
+    stmt.execute("create table " + nonAsciiTableName + " (key int, value string) " +
+        "row format delimited fields terminated by '|'");
+
+    // Load data
+    stmt.execute("load data local inpath '"
+        + nonAsciiFilePath.toString() + "' into table " + nonAsciiTableName);
+
+    ResultSet rs = stmt.executeQuery("select value from " + nonAsciiTableName +  " limit
1");
+    while(rs.next()) {
+      String resultValue = rs.getString(1);
+      assertTrue(resultValue.equalsIgnoreCase(nonAsciiString));
+    }
+
+    // Drop table, ignore error.
+    try {
+      stmt.execute("drop table " + nonAsciiTableName);
+    } catch (Exception ex) {
+      // no-op
+    }
+    stmt.close();
+  }
 }

Modified: hive/branches/branch-0.13/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java?rev=1584146&r1=1584145&r2=1584146&view=diff
==============================================================================
--- hive/branches/branch-0.13/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
(original)
+++ hive/branches/branch-0.13/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java
Wed Apr  2 19:46:57 2014
@@ -20,6 +20,7 @@ package org.apache.hive.service.cli.oper
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
@@ -291,7 +292,11 @@ public class SQLOperation extends Execut
 
     int protocol = getProtocolVersion().getValue();
     for (Object rowString : rows) {
-      rowObj = serde.deserialize(new BytesWritable(((String)rowString).getBytes()));
+      try {
+        rowObj = serde.deserialize(new BytesWritable(((String)rowString).getBytes("UTF-8")));
+      } catch (UnsupportedEncodingException e) {
+        throw new SerDeException(e);
+      }
       for (int i = 0; i < fieldRefs.size(); i++) {
         StructField fieldRef = fieldRefs.get(i);
         fieldOI = fieldRef.getFieldObjectInspector();



Mime
View raw message