phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject phoenix git commit: PHOENIX-2645 Wildcard characters do not match newline characters
Date Tue, 30 Aug 2016 19:16:54 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.8-HBase-1.0 60e3cff75 -> 8c2642c43


PHOENIX-2645 Wildcard characters do not match newline characters


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8c2642c4
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8c2642c4
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8c2642c4

Branch: refs/heads/4.8-HBase-1.0
Commit: 8c2642c43fc35717a91c2f4e061e19a355ea96ab
Parents: 60e3cff
Author: kliewkliew <kliewkliew@users.noreply.github.com>
Authored: Wed Aug 24 03:06:03 2016 -0700
Committer: Thomas D'Silva <twdsilva@gmail.com>
Committed: Tue Aug 30 12:13:36 2016 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/LikeExpressionIT.java       | 29 ++++++++++++++++++++
 .../expression/ByteBasedLikeExpression.java     |  4 ++-
 .../expression/StringBasedLikeExpression.java   |  3 +-
 .../ByteBasedRegexpReplaceFunction.java         |  3 +-
 .../function/ByteBasedRegexpSplitFunction.java  |  3 +-
 .../function/ByteBasedRegexpSubstrFunction.java |  3 +-
 .../StringBasedRegexpReplaceFunction.java       |  3 +-
 .../StringBasedRegexpSubstrFunction.java        |  3 +-
 .../phoenix/expression/LikeExpressionTest.java  |  8 ++++++
 9 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/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 6f056a7..6bfa358 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
@@ -153,4 +153,33 @@ public class LikeExpressionIT extends BaseHBaseManagedTimeTableReuseIT
{
         assertEquals(null, rs.getString(2));
         assertFalse(rs.next());
     }
+
+    @Test
+    public void testNewLine() 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('AA\nA')");
+        conn.commit();
+
+        ResultSet rs = conn.createStatement().executeQuery(
+                "SELECT * FROM " + t + " WHERE k like 'AA%'");
+        assertTrue(rs.next());
+        assertEquals("AA\nA", rs.getString(1));
+
+        rs = conn.createStatement().executeQuery(
+                "SELECT * FROM " + t + " WHERE k like 'AA_A'");
+        assertTrue(rs.next());
+        assertEquals("AA\nA", rs.getString(1));
+
+        rs = conn.createStatement().executeQuery(
+                "SELECT * FROM " + t + " WHERE k like 'AA%A'");
+        assertTrue(rs.next());
+        assertEquals("AA\nA", rs.getString(1));
+
+        rs = conn.createStatement().executeQuery(
+                "SELECT * FROM " + t + " WHERE k like 'AA_'");
+        assertFalse(rs.next());
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/ByteBasedLikeExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/ByteBasedLikeExpression.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ByteBasedLikeExpression.java
index 4dd4f70..5b1dd2e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/ByteBasedLikeExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ByteBasedLikeExpression.java
@@ -18,10 +18,12 @@
 package org.apache.phoenix.expression;
 
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
 import org.apache.phoenix.expression.util.regex.JONIPattern;
 import org.apache.phoenix.parse.LikeParseNode.LikeType;
+import org.joni.Option;
 
 public class ByteBasedLikeExpression extends LikeExpression {
 
@@ -34,7 +36,7 @@ public class ByteBasedLikeExpression extends LikeExpression {
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JONIPattern(value);
+        return new JONIPattern(value, Option.MULTILINE);
     }
 
     public static LikeExpression create(List<Expression> children, LikeType likeType)
{

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/StringBasedLikeExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/StringBasedLikeExpression.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/StringBasedLikeExpression.java
index e2afea2..10c5fd4 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/StringBasedLikeExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/StringBasedLikeExpression.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.expression;
 
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
 import org.apache.phoenix.expression.util.regex.JavaPattern;
@@ -34,7 +35,7 @@ public class StringBasedLikeExpression extends LikeExpression {
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JavaPattern(value);
+        return new JavaPattern(value, Pattern.DOTALL);
     }
 
     public static LikeExpression create(List<Expression> children, LikeType likeType)
{

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpReplaceFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpReplaceFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpReplaceFunction.java
index 0d6543c..c815190 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpReplaceFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpReplaceFunction.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
 import org.apache.phoenix.expression.util.regex.JONIPattern;
+import org.joni.Option;
 
 public class ByteBasedRegexpReplaceFunction extends RegexpReplaceFunction {
 
@@ -34,7 +35,7 @@ public class ByteBasedRegexpReplaceFunction extends RegexpReplaceFunction
{
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JONIPattern(value);
+        return new JONIPattern(value, Option.MULTILINE);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSplitFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSplitFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSplitFunction.java
index 062713e..1a74975 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSplitFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSplitFunction.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.util.regex.AbstractBaseSplitter;
 import org.apache.phoenix.expression.util.regex.JONIPattern;
+import org.joni.Option;
 
 public class ByteBasedRegexpSplitFunction extends RegexpSplitFunction {
     public ByteBasedRegexpSplitFunction() {
@@ -33,6 +34,6 @@ public class ByteBasedRegexpSplitFunction extends RegexpSplitFunction {
 
     @Override
     protected AbstractBaseSplitter compilePatternSpec(String value) {
-        return new JONIPattern(value);
+        return new JONIPattern(value, Option.MULTILINE);
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSubstrFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSubstrFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSubstrFunction.java
index 7ee99bf..96e5353 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSubstrFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ByteBasedRegexpSubstrFunction.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
 import org.apache.phoenix.expression.util.regex.JONIPattern;
+import org.joni.Option;
 
 public class ByteBasedRegexpSubstrFunction extends RegexpSubstrFunction {
     public ByteBasedRegexpSubstrFunction() {
@@ -33,6 +34,6 @@ public class ByteBasedRegexpSubstrFunction extends RegexpSubstrFunction
{
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JONIPattern(value);
+        return new JONIPattern(value, Option.MULTILINE);
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpReplaceFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpReplaceFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpReplaceFunction.java
index 9aaec70..1e4943f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpReplaceFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpReplaceFunction.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.expression.function;
 
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
@@ -34,7 +35,7 @@ public class StringBasedRegexpReplaceFunction extends RegexpReplaceFunction
{
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JavaPattern(value);
+        return new JavaPattern(value, Pattern.DOTALL);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpSubstrFunction.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpSubstrFunction.java
b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpSubstrFunction.java
index 253db36..5e82a32 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpSubstrFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/StringBasedRegexpSubstrFunction.java
@@ -18,6 +18,7 @@
 package org.apache.phoenix.expression.function;
 
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.util.regex.AbstractBasePattern;
@@ -33,6 +34,6 @@ public class StringBasedRegexpSubstrFunction extends RegexpSubstrFunction
{
 
     @Override
     protected AbstractBasePattern compilePatternSpec(String value) {
-        return new JavaPattern(value);
+        return new JavaPattern(value, Pattern.DOTALL);
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c2642c4/phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java
index 0bf8b06..580ac8e 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/expression/LikeExpressionTest.java
@@ -81,4 +81,12 @@ public class LikeExpressionTest {
         assertEquals(Boolean.TRUE, testExpression ("", "%"));
         assertEquals(Boolean.FALSE, testExpression ("", "_"));
     }
+
+    @Test
+    public void testNewline() throws Exception {
+        assertEquals(Boolean.TRUE, testExpression ("AA\nA", "AA%"));
+        assertEquals(Boolean.TRUE, testExpression ("AA\nA", "AA_A"));
+        assertEquals(Boolean.TRUE, testExpression ("AA\nA", "AA%A"));
+        assertEquals(Boolean.FALSE, testExpression ("AA\nA", "AA_"));
+    }
  }


Mime
View raw message