You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2015/08/23 19:15:37 UTC
[12/40] phoenix git commit: PHOENIX-2139 LIKE '%' is not filtering
out null columns
PHOENIX-2139 LIKE '%' is not filtering out null columns
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a50ead27
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a50ead27
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a50ead27
Branch: refs/heads/calcite
Commit: a50ead27afa467f6d530052354ac741fb8aa1307
Parents: f00c777
Author: James Taylor <ja...@apache.org>
Authored: Wed Jul 22 16:12:15 2015 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Wed Jul 22 16:13:17 2015 -0700
----------------------------------------------------------------------
.../phoenix/end2end/LikeExpressionIT.java | 38 ++++++++++++++++++++
.../phoenix/compile/ExpressionCompiler.java | 2 ++
2 files changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a50ead27/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 1ee0669..1d93341 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
@@ -85,4 +85,42 @@ public class LikeExpressionIT extends BaseHBaseManagedTimeIT {
testLikeExpression(conn, "%A%", 3, 42);
conn.close();
}
+
+ @Test
+ public void testLikeEverythingExpression() throws Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+ String ddl = "CREATE TABLE t (k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))";
+ conn.createStatement().execute(ddl);
+ conn.createStatement().execute("UPSERT INTO t VALUES('aa','bb')");
+ conn.createStatement().execute("UPSERT INTO t VALUES('ab','bc')");
+ conn.createStatement().execute("UPSERT INTO t VALUES(null,'cc')");
+ conn.createStatement().execute("UPSERT INTO t VALUES('dd',null)");
+ conn.commit();
+
+ ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM t WHERE k1 LIKE '%'");
+ assertTrue(rs.next());
+ assertEquals("aa", rs.getString(1));
+ assertEquals("bb", rs.getString(2));
+ assertTrue(rs.next());
+ assertEquals("ab", rs.getString(1));
+ assertEquals("bc", rs.getString(2));
+ assertTrue(rs.next());
+ assertEquals("dd", rs.getString(1));
+ assertEquals(null, rs.getString(2));
+ assertFalse(rs.next());
+
+ rs = conn.createStatement().executeQuery("SELECT * FROM t WHERE k2 LIKE '%'");
+ assertTrue(rs.next());
+ assertEquals(null, rs.getString(1));
+ assertEquals("cc", rs.getString(2));
+ assertTrue(rs.next());
+ assertEquals("aa", rs.getString(1));
+ assertEquals("bb", rs.getString(2));
+ assertTrue(rs.next());
+ assertEquals("ab", rs.getString(1));
+ assertEquals("bc", rs.getString(2));
+ assertFalse(rs.next());
+
+ conn.close();
+ }
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/a50ead27/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 2f786ec..1278494 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
@@ -513,6 +513,8 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
return new ComparisonExpression(Arrays.asList(lhs,rhs), op);
}
}
+ } else if (index == 0 && pattern.length() == 1) {
+ return IsNullExpression.create(lhs, true, context.getTempPtr());
}
}
QueryServices services = context.getConnection().getQueryServices();