Github user BinShi-SecularBird commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/347#discussion_r223111306
--- Diff:
phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java
---
@@ -823,12 +823,189 @@ private void testSelectQueriesWithFilters(boolean
useStatsForParallelization) th
assertEquals(100 + i, rs.getInt(1));
i++;
}
+ assertEquals(numRows, i);
+ info = getByteRowEstimates(conn, sql, binds);
+ // Depending on the guidepost boundary, this estimate
+ // can be slightly off. It's called estimate for a reason.
+ assertEquals((Long) 3L, info.getEstimatedRows());
+ assertEquals((Long) 160L, info.getEstimatedBytes());
+ assertTrue(info.getEstimateInfoTs() > 0);
+ // Query whose start key is between and end key is after data.
+ sql = "SELECT a FROM " + tableName + " WHERE K <= 120 AND K >=
100";
+ rs = conn.createStatement().executeQuery(sql);
+ i = 0;
+ numRows = 10;
+ while (rs.next()) {
+ assertEquals(100 + i, rs.getInt(1));
+ i++;
+ }
+ assertEquals(numRows, i);
+ info = getByteRowEstimates(conn, sql, binds);
+ // Depending on the guidepost boundary, this estimate
+ // can be slightly off. It's called estimate for a reason.
+ assertEquals((Long) 10L, info.getEstimatedRows());
+ assertEquals((Long) 720L, info.getEstimatedBytes());
+ assertTrue(info.getEstimateInfoTs() > 0);
+ // Query whose start key and end key are both between data.
+ sql = "SELECT a FROM " + tableName + " WHERE K <= 109 AND K >=
100";
+ rs = conn.createStatement().executeQuery(sql);
+ i = 0;
+ numRows = 10;
+ while (rs.next()) {
+ assertEquals(100 + i, rs.getInt(1));
+ i++;
+ }
+ assertEquals(numRows, i);
+ info = getByteRowEstimates(conn, sql, binds);
+ // Depending on the guidepost boundary, this estimate
+ // can be slightly off. It's called estimate for a reason.
+ assertEquals((Long) 10L, info.getEstimatedRows());
+ assertEquals((Long) 720L, info.getEstimatedBytes());
+ assertTrue(info.getEstimateInfoTs() > 0);
+ }
+ }
+
+ @Test
+ public void testSelectQueriesWithGuidePostMovingWindows() throws
Exception {
+ testSelectQueriesWithGuidePostMovingWindows(0);
+ testSelectQueriesWithGuidePostMovingWindows(1);
+ testSelectQueriesWithGuidePostMovingWindows(2);
+ testSelectQueriesWithGuidePostMovingWindows(10);
+ testSelectQueriesWithGuidePostMovingWindows(256);
+ }
+
+ private void testSelectQueriesWithGuidePostMovingWindows(int
movingWindowSize) throws Exception {
+ String tableName = generateUniqueName();
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ int guidePostWidth = 20;
+ String ddl =
+ "CREATE TABLE " + tableName + " (k INTEGER PRIMARY
KEY, a bigint, b bigint)"
+ + " GUIDE_POSTS_WIDTH=" + guidePostWidth
+ + ", USE_STATS_FOR_PARALLELIZATION=true" + "
SPLIT ON (102, 105, 108)";
+ conn.createStatement().execute(ddl);
--- End diff --
I'll hold this change as discussed in PHOENIX-4594.
---