phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject [28/50] [abbrv] phoenix git commit: PHOENIX-4397 Incorrect query results when with stats are disabled on a salted table
Date Fri, 19 Jan 2018 18:03:36 GMT
PHOENIX-4397 Incorrect query results when with stats are disabled on a salted table


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

Branch: refs/heads/system-catalog
Commit: 72bc8190272480fae17475398ef492a3071a3a44
Parents: d6e61af
Author: Samarth Jain <samarth@apache.org>
Authored: Fri Dec 8 14:40:22 2017 -0800
Committer: Samarth Jain <samarth@apache.org>
Committed: Fri Dec 8 14:40:22 2017 -0800

----------------------------------------------------------------------
 .../end2end/ExplainPlanWithStatsEnabledIT.java  | 36 ++++++++++++++++++++
 .../phoenix/iterate/BaseResultIterators.java    |  6 +---
 2 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/72bc8190/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
index bfc6819..49efa97 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
@@ -1068,4 +1068,40 @@ public class ExplainPlanWithStatsEnabledIT extends ParallelStatsEnabledIT
{
                     .getQueryPlan().getScans().get(0).size());
         }
     }
+
+    @Test
+    public void testQueryingWithUseStatsForParallelizationOnOff() throws SQLException {
+        testUseStatsForParallelizationOnSaltedTable(true, true);
+        testUseStatsForParallelizationOnSaltedTable(true, false);
+        testUseStatsForParallelizationOnSaltedTable(false, true);
+        testUseStatsForParallelizationOnSaltedTable(false, false);
+    }
+
+    private void testUseStatsForParallelizationOnSaltedTable(boolean useStatsFlag, boolean
salted)
+            throws SQLException {
+        String tableName = generateUniqueName();
+        Connection conn = DriverManager.getConnection(getUrl());
+        conn.createStatement().execute(
+            "create table " + tableName + "(k varchar not null primary key, v varchar) "
+                    + (salted ? " SALT_BUCKETS=2," : "") + " USE_STATS_FOR_PARALLELIZATION="
+                    + useStatsFlag);
+        conn.createStatement().execute("upsert into " + tableName + " values ('1', 'B')");
+        conn.createStatement().execute("upsert into " + tableName + " values ('2', 'A')");
+        conn.commit();
+        String query = "SELECT V FROM " + tableName + " ORDER BY V";
+        ResultSet rs = conn.createStatement().executeQuery(query);
+        assertTrue(rs.next());
+        assertEquals("A", rs.getString(1));
+        assertTrue(rs.next());
+        assertEquals("B", rs.getString(1));
+
+        // Collect stats and make sure query still works correctly
+        conn.createStatement().execute("UPDATE STATISTICS " + tableName);
+        rs = conn.createStatement().executeQuery(query);
+        assertTrue(rs.next());
+        assertEquals("A", rs.getString(1));
+        assertTrue(rs.next());
+        assertEquals("B", rs.getString(1));
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/72bc8190/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
index eb09813..bd67fa8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -607,11 +607,7 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
                 estimate.bytesEstimate += gpsBytes;
             }
         }
-        if (startNewScan && !scans.isEmpty() && useStatsForParallelization)
{
-            /*
-             * Note that even if region boundary was crossed, if we are not using stats for
-             * parallelization, nothing gets added to the parallel scans.
-             */
+        if (startNewScan && !scans.isEmpty()) {
             parallelScans.add(scans);
             scans = Lists.newArrayListWithExpectedSize(1);
         }


Mime
View raw message