Repository: phoenix Updated Branches: refs/heads/4.0 4c8441b5f -> 7cdc43770
PHOENIX-1225 Evaluation of OR between columns in PK and not in PK incorrect (ycchung, shcchen, kathylin, NTHU-SSLAB) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7cdc4377 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7cdc4377 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7cdc4377 Branch: refs/heads/4.0 Commit: 7cdc437702087071e45e722356532b3658357078 Parents: 4c8441b Author: James Taylor <[email protected]> Authored: Sat Sep 6 12:15:05 2014 -0700 Committer: James Taylor <[email protected]> Committed: Sat Sep 6 12:15:05 2014 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/EvaluationOfORIT.java | 176 +++++++++++++++++++ .../apache/phoenix/compile/WhereOptimizer.java | 2 +- 2 files changed, 177 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7cdc4377/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java new file mode 100644 index 0000000..052ff43 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java @@ -0,0 +1,176 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.end2end; + +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; + +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(BaseHBaseManagedTimeIT.class) +public class EvaluationOfORIT extends BaseHBaseManagedTimeIT{ + + @Test + public void testPKOrNotPKInOREvaluation() throws SQLException { + Properties props = new Properties(TEST_PROPERTIES); + Connection conn = DriverManager.getConnection(getUrl(), props); + conn.setAutoCommit(false); + + String create = "CREATE TABLE DIE ( ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(50) NOT NULL)"; + PreparedStatement createStmt = conn.prepareStatement(create); + createStmt.executeUpdate(); + PreparedStatement stmt = conn.prepareStatement( + "upsert into " + + "DIE VALUES (?, ?)"); + + stmt.setInt(1, 1); + stmt.setString(2, "Tester1"); + stmt.execute(); + + stmt.setInt(1,2); + stmt.setString(2, "Tester2"); + stmt.execute(); + + stmt.setInt(1,3); + stmt.setString(2, "Tester3"); + stmt.execute(); + + stmt.setInt(1,4); + stmt.setString(2, "LikeTester1"); + stmt.execute(); + + stmt.setInt(1,5); + stmt.setString(2, "LikeTester2"); + stmt.execute(); + + stmt.setInt(1,6); + stmt.setString(2, "LikeTesterEnd"); + stmt.execute(); + + stmt.setInt(1,7); + stmt.setString(2, "LikeTesterEnd2"); + stmt.execute(); + + stmt.setInt(1,8); + stmt.setString(2, "Tester3"); + stmt.execute(); + + stmt.setInt(1,9); + stmt.setString(2, "Tester4"); + stmt.execute(); + + stmt.setInt(1,10); + stmt.setString(2, "Tester5"); + stmt.execute(); + + stmt.setInt(1,11); + stmt.setString(2, "Tester6"); + stmt.execute(); + + stmt.setInt(1,12); + stmt.setString(2, "tester6"); + stmt.execute(); + + stmt.setInt(1,13); + stmt.setString(2, "lester1"); + stmt.execute(); + + stmt.setInt(1,14); + stmt.setString(2, "le50ster1"); + stmt.execute(); + + stmt.setInt(1,15); + stmt.setString(2, "LE50ster1"); + stmt.execute(); + + stmt.setInt(1,16); + stmt.setString(2, "LiketesterEnd"); + stmt.execute(); + + stmt.setInt(1,17); + stmt.setString(2, "la50ster1"); + stmt.execute(); + + stmt.setInt(1,18); + stmt.setString(2, "lA50ster0"); + stmt.execute(); + + stmt.setInt(1,19); + stmt.setString(2, "lA50ster2"); + stmt.execute(); + + stmt.setInt(1,20); + stmt.setString(2, "la50ster0"); + stmt.execute(); + + stmt.setInt(1,21); + stmt.setString(2, "la50ster2"); + stmt.execute(); + + stmt.setInt(1,22); + stmt.setString(2, "La50ster3"); + stmt.execute(); + + stmt.setInt(1,23); + stmt.setString(2, "la50ster3"); + stmt.execute(); + + stmt.setInt(1,24); + stmt.setString(2, "l[50ster3"); + stmt.execute(); + + stmt.setInt(1,25); + stmt.setString(2, "Tester1"); + stmt.execute(); + + stmt.setInt(1,26); + stmt.setString(2, "Tester100"); + stmt.execute(); + conn.commit(); + + String select = "Select * from DIE where ID=6 or Name between 'Tester1' and 'Tester3'"; + ResultSet rs; + rs = conn.createStatement().executeQuery(select); + assertTrue(rs.next()); + assertEquals(1,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(2,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(3,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(6,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(8,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(25,rs.getInt(1)); + assertTrue(rs.next()); + assertEquals(26,rs.getInt(1)); + conn.close(); + } + + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/7cdc4377/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java index 635dbc4..5e03158 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java @@ -685,7 +685,7 @@ public class WhereOptimizer { for (KeySlot slot : childSlot) { // We have a nested OR with nothing for this slot, so continue if (slot == null) { - continue; // FIXME: I don't think this is ever necessary + return null; //If one childSlot does not have the PK columns, let Phoenix scan all the key ranges of the table. } /* * If we see a different PK column than before, we can't
