Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9E75510A71 for ; Thu, 10 Oct 2013 16:01:56 +0000 (UTC) Received: (qmail 46188 invoked by uid 500); 10 Oct 2013 16:01:55 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 46137 invoked by uid 500); 10 Oct 2013 16:01:55 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 46128 invoked by uid 99); 10 Oct 2013 16:01:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 16:01:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 16:01:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 26F112388831; Thu, 10 Oct 2013 16:01:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hive.apache.org From: hashutosh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131010160133.26F112388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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;