Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EF446200B7E for ; Tue, 6 Sep 2016 20:25:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EDD08160ACB; Tue, 6 Sep 2016 18:25:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 400F8160AA9 for ; Tue, 6 Sep 2016 20:25:37 +0200 (CEST) Received: (qmail 76045 invoked by uid 500); 6 Sep 2016 18:25:36 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 76035 invoked by uid 99); 6 Sep 2016 18:25:36 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 18:25:36 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 535AFE009E; Tue, 6 Sep 2016 18:25:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tdsilva@apache.org To: commits@phoenix.apache.org Message-Id: <644253a61a724c0da9d78c1f46d1f858@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-2641 Implicit wildcard in LIKE predicate search pattern Date: Tue, 6 Sep 2016 18:25:36 +0000 (UTC) archived-at: Tue, 06 Sep 2016 18:25:38 -0000 Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 dc552d990 -> 7ed731877 PHOENIX-2641 Implicit wildcard in LIKE predicate search pattern This closes #200 Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7ed73187 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7ed73187 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7ed73187 Branch: refs/heads/4.x-HBase-0.98 Commit: 7ed7318771d5c0ed47e5d6d449f92911dfa902bc Parents: dc552d9 Author: kliewkliew Authored: Wed Aug 24 06:40:35 2016 -0700 Committer: Thomas D'Silva Committed: Tue Sep 6 11:19:37 2016 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/LikeExpressionIT.java | 23 ++++++++++++++++++++ .../phoenix/compile/ExpressionCompiler.java | 10 +++++++-- .../phoenix/expression/LikeExpressionTest.java | 6 +++++ 3 files changed, 37 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7ed73187/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java index 6bfa358..f97e1d7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java @@ -182,4 +182,27 @@ public class LikeExpressionIT extends BaseHBaseManagedTimeTableReuseIT { "SELECT * FROM " + t + " WHERE k like 'AA_'"); assertFalse(rs.next()); } + + @Test + public void testOneChar() throws Exception { + Connection conn = DriverManager.getConnection(getUrl()); + String t = generateRandomString(); + String ddl = "CREATE TABLE " + t + " (k VARCHAR NOT NULL PRIMARY KEY)"; + conn.createStatement().execute(ddl); + conn.createStatement().execute("UPSERT INTO " + t + " VALUES('A')"); + conn.createStatement().execute("UPSERT INTO " + t + " VALUES('AA')"); + conn.commit(); + + ResultSet rs = conn.createStatement().executeQuery( + "SELECT * FROM " + t + " WHERE k like '_'"); + assertTrue(rs.next()); + assertEquals("A", rs.getString(1)); + assertFalse(rs.next()); + + rs = conn.createStatement().executeQuery( + "SELECT * FROM " + t + " WHERE k like '_A'"); + assertTrue(rs.next()); + assertEquals("AA", rs.getString(1)); + assertFalse(rs.next()); + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/7ed73187/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java index 0fd1876..aaab763 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java @@ -136,6 +136,7 @@ import org.apache.phoenix.schema.types.PhoenixArray; import org.apache.phoenix.util.ExpressionUtil; import org.apache.phoenix.util.IndexUtil; import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.StringUtil; public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor { @@ -517,8 +518,13 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor