You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2017/04/06 17:32:09 UTC
[3/7] phoenix git commit: PHOENIX-3476: prevent loss of offset when
sub-aggregating (Matthew Silverman)
PHOENIX-3476: prevent loss of offset when sub-aggregating (Matthew Silverman)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2074d1f0
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2074d1f0
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2074d1f0
Branch: refs/heads/calcite
Commit: 2074d1f0a2dd2b03c2e3588ffd4d5f2395cc7505
Parents: 7050b92
Author: James Taylor <ja...@apache.org>
Authored: Tue Mar 21 15:48:36 2017 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Tue Mar 21 15:48:36 2017 -0700
----------------------------------------------------------------------
.../phoenix/end2end/NthValueFunctionIT.java | 34 ++++++++++++++++++++
.../FirstLastValueServerAggregator.java | 2 --
2 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2074d1f0/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java
index 1278e26..ff0f094 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java
@@ -128,6 +128,40 @@ public class NthValueFunctionIT extends ParallelStatsDisabledIT {
}
@Test
+ public void offsetValueSubAggregation() throws Exception {
+ Connection conn = DriverManager.getConnection(getUrl());
+
+ String nth_test_table = generateUniqueName();
+ String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " "
+ + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG,"
+ + " \"DATE\" INTEGER, \"value\" UNSIGNED_LONG)";
+ conn.createStatement().execute(ddl);
+
+ conn.createStatement().execute("UPSERT INTO " + nth_test_table
+ + " (id, page_id, \"DATE\", \"value\") VALUES (1, 8, 0, 300)");
+ conn.createStatement().execute(
+ "UPSERT INTO " + nth_test_table + " (id, page_id, \"DATE\", \"value\") VALUES (2, 8, 1, 7)");
+ conn.createStatement().execute(
+ "UPSERT INTO " + nth_test_table + " (id, page_id, \"DATE\", \"value\") VALUES (3, 9, 2, 9)");
+ conn.createStatement().execute(
+ "UPSERT INTO " + nth_test_table + " (id, page_id, \"DATE\", \"value\") VALUES (4, 9, 3, 4)");
+ conn.createStatement().execute(
+ "UPSERT INTO " + nth_test_table + " (id, page_id, \"DATE\", \"value\") VALUES (5, 10, 4, 2)");
+ conn.createStatement().execute("UPSERT INTO " + nth_test_table
+ + " (id, page_id, \"DATE\", \"value\") VALUES (6, 10, 5, 150)");
+ conn.commit();
+
+ ResultSet rs = conn.createStatement().executeQuery(
+ "SELECT NTH_VALUE(SUM_VALUE, 2) WITHIN GROUP (ORDER BY MIN_DATE ASC) FROM (" +
+ "SELECT MIN(\"DATE\") AS MIN_DATE, SUM(\"value\") AS SUM_VALUE FROM "
+ + nth_test_table + " GROUP BY page_id) x");
+
+ assertTrue(rs.next());
+ assertEquals(13, rs.getLong(1));
+ assertFalse(rs.next());
+ }
+
+ @Test
public void offsetValueLastMismatchByColumn() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2074d1f0/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
index 273b890..66b38c6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
@@ -64,8 +64,6 @@ public class FirstLastValueServerAggregator extends BaseAggregator {
topValue = null;
topValues.clear();
topValuesCount = 0;
- offset = -1;
- useOffset = false;
}
@Override