phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: PHOENIX-2601 Query result is incorrect when both index hint and limit are used
Date Sat, 16 Jan 2016 03:39:11 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 d85365618 -> 9d7c328a2


PHOENIX-2601 Query result is incorrect when both index hint and limit are used


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 9d7c328a2d0089c0ec819c41a0a54fda1e8d3ff0
Parents: d853656
Author: maryannxue <maryann.xue@gmail.com>
Authored: Fri Jan 15 22:38:58 2016 -0500
Committer: maryannxue <maryann.xue@gmail.com>
Committed: Fri Jan 15 22:38:58 2016 -0500

----------------------------------------------------------------------
 .../index/GlobalIndexOptimizationIT.java        | 23 ++++++++++++++++++++
 .../apache/phoenix/optimize/QueryOptimizer.java |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9d7c328a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
index b97176f..10634b8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
@@ -157,6 +157,29 @@ public class GlobalIndexOptimizationIT extends BaseHBaseManagedTimeIT
{
             assertEquals("a", rs.getString("v1"));
             assertFalse(rs.next());
             
+            query = "SELECT /*+ INDEX(" + TestUtil.DEFAULT_DATA_TABLE_NAME + " " + TestUtil.DEFAULT_INDEX_TABLE_NAME
+ ")*/ * FROM " + TestUtil.DEFAULT_DATA_TABLE_NAME +" where v1='a' limit 1";
+            rs = conn1.createStatement().executeQuery("EXPLAIN "+ query);
+            
+            expected = 
+                    "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + TestUtil.DEFAULT_DATA_TABLE_NAME
+ "\n" +
+                    "CLIENT 1 ROW LIMIT\n" +
+                    "    SKIP-SCAN-JOIN TABLE 0\n" +
+                    "        CLIENT PARALLEL 1-WAY RANGE SCAN OVER " + TestUtil.DEFAULT_INDEX_TABLE_NAME
+ " \\['a'\\]\n" +
+                    "            SERVER FILTER BY FIRST KEY ONLY\n" +
+                    "    DYNAMIC SERVER FILTER BY \\(\"T.T_ID\", \"T.K1\", \"T.K2\"\\) IN
\\(\\(\\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+\\)\\)\n" +
+                    "    JOIN-SCANNER 1 ROW LIMIT";
+            actual = QueryUtil.getExplainPlan(rs);
+            assertTrue("Expected:\n" + expected + "\nbut got\n" + actual, Pattern.matches(expected,
actual));
+            
+            rs = conn1.createStatement().executeQuery(query);
+            assertTrue(rs.next());
+            assertEquals("f", rs.getString("t_id"));
+            assertEquals(1, rs.getInt("k1"));
+            assertEquals(2, rs.getInt("k2"));
+            assertEquals(3, rs.getInt("k3"));
+            assertEquals("a", rs.getString("v1"));
+            assertFalse(rs.next());
+            
             query = "SELECT /*+ INDEX(" + TestUtil.DEFAULT_DATA_TABLE_NAME + " " + TestUtil.DEFAULT_INDEX_TABLE_NAME
+ ")*/ t_id, k1, k2, k3, V1 from " + TestUtil.DEFAULT_DATA_TABLE_FULL_NAME + "  where v1<='z'
and k3 > 1 order by V1,t_id";
             rs = conn1.createStatement().executeQuery("EXPLAIN " + query);
             

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9d7c328a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index c5ff3c6..adc3c2d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -285,7 +285,7 @@ public class QueryOptimizer {
                             aliasedNodes.add(FACTORY.aliasedNode(null, indexColNode));
                             nodes.add(new ColumnParseNode(null, '"' + column.getName().getString()
+ '"'));
                         }
-                        SelectStatement innerSelect = FACTORY.select(indexSelect.getFrom(),
indexSelect.getHint(), false, aliasedNodes, where, null, null, null, indexSelect.getLimit(),
indexSelect.getBindCount(), false, indexSelect.hasSequence(), Collections.<SelectStatement>emptyList(),
indexSelect.getUdfParseNodes());
+                        SelectStatement innerSelect = FACTORY.select(indexSelect.getFrom(),
indexSelect.getHint(), false, aliasedNodes, where, null, null, null, null, indexSelect.getBindCount(),
false, indexSelect.hasSequence(), Collections.<SelectStatement>emptyList(), indexSelect.getUdfParseNodes());
                         ParseNode outerWhere = FACTORY.in(nodes.size() == 1 ? nodes.get(0)
: FACTORY.rowValueConstructor(nodes), FACTORY.subquery(innerSelect, false), false, true);
                         ParseNode extractedCondition = whereRewriter.getExtractedCondition();
                         if (extractedCondition != null) {


Mime
View raw message