Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F2B0018636 for ; Mon, 27 Jul 2015 18:50:50 +0000 (UTC) Received: (qmail 26986 invoked by uid 500); 27 Jul 2015 18:50:28 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 26957 invoked by uid 500); 27 Jul 2015 18:50:28 -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 26947 invoked by uid 99); 27 Jul 2015 18:50:28 -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; Mon, 27 Jul 2015 18:50:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8E366E04B0; Mon, 27 Jul 2015 18:50:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: maryannxue@apache.org To: commits@phoenix.apache.org Message-Id: <9e74299412fb49429b0ec9f3b4519764@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-2141 ComparisonExpression should return Boolean null if either operand is null Date: Mon, 27 Jul 2015 18:50:28 +0000 (UTC) Repository: phoenix Updated Branches: refs/heads/master 69f22b515 -> c0d0c79e1 PHOENIX-2141 ComparisonExpression should return Boolean null if either operand is null Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c0d0c79e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c0d0c79e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c0d0c79e Branch: refs/heads/master Commit: c0d0c79e1ca487d69a036b36dda280e20a6ed7e5 Parents: 69f22b5 Author: maryannxue Authored: Mon Jul 27 14:50:16 2015 -0400 Committer: maryannxue Committed: Mon Jul 27 14:50:16 2015 -0400 ---------------------------------------------------------------------- .../phoenix/compile/ExpressionCompiler.java | 3 + .../apache/phoenix/compile/HavingCompiler.java | 2 +- .../apache/phoenix/compile/WhereCompiler.java | 2 +- .../apache/phoenix/compile/WhereOptimizer.java | 2 +- .../phoenix/expression/AndExpression.java | 3 + .../expression/ComparisonExpression.java | 4 +- .../phoenix/expression/LiteralExpression.java | 23 ++++++-- .../phoenix/expression/NullValueTest.java | 59 ++++++++++++++++++++ 8 files changed, 89 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/c0d0c79e/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 1278494..1523dce 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 @@ -251,6 +251,9 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor= ''", + "SELECT '' < 'a'", + "SELECT '' = ''"}; + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection conn = DriverManager.getConnection(getUrl(), props); + try { + for (String q : query) { + ResultSet rs = conn.createStatement().executeQuery(q); + assertTrue(rs.next()); + assertNull(rs.getObject(1)); + assertEquals(false, rs.getBoolean(1)); + assertFalse(rs.next()); + } + } finally { + conn.close(); + } + } + + @Test + public void testAndOrExpressionWithNullOperands() throws Exception { + String[] query = {"SELECT 'a' >= '' or '' < 'a'", + "SELECT 'a' >= '' and '' < 'a'"}; + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection conn = DriverManager.getConnection(getUrl(), props); + try { + for (String q : query) { + ResultSet rs = conn.createStatement().executeQuery(q); + assertTrue(rs.next()); + assertNull(rs.getObject(1)); + assertEquals(false, rs.getBoolean(1)); + assertFalse(rs.next()); + } + } finally { + conn.close(); + } + } + +}