hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1531035 - in /hive/trunk/ql/src: java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
Date Thu, 10 Oct 2013 16:01:33 GMT
Author: hashutosh
Date: Thu Oct 10 16:01:32 2013
New Revision: 1531035

URL: http://svn.apache.org/r1531035
Log:
HIVE-5490 : SUBSTR(col, 1, 0) returns wrong result in vectorized mode (Teddy Choi via Ashutosh
Chauhan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
    hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java?rev=1531035&r1=1531034&r2=1531035&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
(original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java
Thu Oct 10 16:01:32 2013
@@ -110,6 +110,10 @@ public class StringSubstrColStartLen ext
       substrStart = length + substrStart;
     }
 
+    if (substrLength == 0) {
+      return;
+    }
+
     int endIdx = substrStart + substrLength - 1;
     for (int i = start; i != end; ++i) {
       if ((utf8String[i] & 0xc0) != 0x80) {

Modified: hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java?rev=1531035&r1=1531034&r2=1531035&view=diff
==============================================================================
--- hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
(original)
+++ hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java
Thu Oct 10 16:01:32 2013
@@ -1570,6 +1570,36 @@ public class TestVectorStringExpressions
         )
     );
 
+    //Testing substring index starting with 1 and zero length
+
+    outV.isRepeating = true;
+    outV.noNulls = false;
+
+    expr = new StringSubstrColStartLen(0, 1, 0, 1);
+    outCol = (BytesColumnVector) batch.cols[1];
+    expr.evaluate(batch);
+    Assert.assertEquals(3, batch.size);
+    Assert.assertTrue(outCol.noNulls);
+    Assert.assertFalse(outCol.isRepeating);
+    Assert.assertEquals(0,
+        StringExpr.compare(
+            data1, 1, 0, outCol.vector[0], outCol.start[0], outCol.length[0]
+        )
+    );
+
+    Assert.assertEquals(0,
+        StringExpr.compare(
+            data2, 1, 0, outCol.vector[1], outCol.start[1], outCol.length[1]
+        )
+    );
+
+    Assert.assertEquals(0,
+        StringExpr.compare(
+            data3, 1, 0, outCol.vector[2], outCol.start[2], outCol.length[2]
+        )
+    );
+
+
     //Testing substring index starting with 0 and length equal to array length
 
     outV.isRepeating = true;



Mime
View raw message