phoenix git commit: PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai)
Repository: phoenix Updated Branches: refs/heads/master e2b6009f2 -> 5176ed637 PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/5176ed63 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/5176ed63 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/5176ed63 Branch: refs/heads/master Commit: 5176ed6371778daa58300592620483b619b668fb Parents: e2b6009 Author: Dumindu BuddhikaAuthored: Tue Jan 26 08:29:15 2016 +0530 Committer: Dumindu Buddhika Committed: Tue Jan 26 08:29:15 2016 +0530 -- .../main/java/org/apache/phoenix/query/QueryServicesOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/5176ed63/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java index c9bc19b..1838b51 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java @@ -103,7 +103,7 @@ public class QueryServicesOptions { public static final int DEFAULT_QUEUE_SIZE = 5000; public static final int DEFAULT_THREAD_TIMEOUT_MS = 60; // 10min public static final int DEFAULT_SPOOL_THRESHOLD_BYTES = 1024 * 1024 * 20; // 20m -public static final String DEFAULT_SPOOL_DIRECTORY = "/tmp"; +public static final String DEFAULT_SPOOL_DIRECTORY = System.getProperty("java.io.tmpdir"); public static final int DEFAULT_MAX_MEMORY_PERC = 15; // 15% of heap public static final int DEFAULT_MAX_MEMORY_WAIT_MS = 1; public static final int DEFAULT_MAX_TENANT_MEMORY_PERC = 100;
phoenix git commit: PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai)
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 8e0e7a265 -> d1ee4ce9c PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d1ee4ce9 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d1ee4ce9 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d1ee4ce9 Branch: refs/heads/4.x-HBase-0.98 Commit: d1ee4ce9c24e9c541598e593cc41309611cb92a9 Parents: 8e0e7a2 Author: Dumindu BuddhikaAuthored: Tue Jan 26 08:33:31 2016 +0530 Committer: Dumindu Buddhika Committed: Tue Jan 26 08:33:31 2016 +0530 -- .../main/java/org/apache/phoenix/query/QueryServicesOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/d1ee4ce9/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java index 69a1ff7..9bc5e3b 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java @@ -102,7 +102,7 @@ public class QueryServicesOptions { public static final int DEFAULT_QUEUE_SIZE = 5000; public static final int DEFAULT_THREAD_TIMEOUT_MS = 60; // 10min public static final int DEFAULT_SPOOL_THRESHOLD_BYTES = 1024 * 1024 * 20; // 20m -public static final String DEFAULT_SPOOL_DIRECTORY = "/tmp"; +public static final String DEFAULT_SPOOL_DIRECTORY = System.getProperty("java.io.tmpdir"); public static final int DEFAULT_MAX_MEMORY_PERC = 15; // 15% of heap public static final int DEFAULT_MAX_MEMORY_WAIT_MS = 1; public static final int DEFAULT_MAX_TENANT_MEMORY_PERC = 100;
phoenix git commit: PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai)
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.0 eaaa48791 -> ff8688b01 PHOENIX-2348 The value of DEFAULT_SPOOL_DIRECTORY is invalid on Windows (ChiaPing Tsai) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ff8688b0 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ff8688b0 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ff8688b0 Branch: refs/heads/4.x-HBase-1.0 Commit: ff8688b01afd9fe9d4baa60ddcedf2d102aaf4a7 Parents: eaaa487 Author: Dumindu BuddhikaAuthored: Tue Jan 26 08:36:50 2016 +0530 Committer: Dumindu Buddhika Committed: Tue Jan 26 08:36:50 2016 +0530 -- .../main/java/org/apache/phoenix/query/QueryServicesOptions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ff8688b0/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java index 5642196..f8ca309 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java @@ -104,7 +104,7 @@ public class QueryServicesOptions { public static final int DEFAULT_QUEUE_SIZE = 5000; public static final int DEFAULT_THREAD_TIMEOUT_MS = 60; // 10min public static final int DEFAULT_SPOOL_THRESHOLD_BYTES = 1024 * 1024 * 20; // 20m -public static final String DEFAULT_SPOOL_DIRECTORY = "/tmp"; +public static final String DEFAULT_SPOOL_DIRECTORY = System.getProperty("java.io.tmpdir"); public static final int DEFAULT_MAX_MEMORY_PERC = 15; // 15% of heap public static final int DEFAULT_MAX_MEMORY_WAIT_MS = 1; public static final int DEFAULT_MAX_TENANT_MEMORY_PERC = 100;
phoenix git commit: PHOENIX-2301 NullPointerException when upserting into a char array column
Repository: phoenix Updated Branches: refs/heads/master 016b2b96e -> 7afa91ab9 PHOENIX-2301 NullPointerException when upserting into a char array column Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7afa91ab Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7afa91ab Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7afa91ab Branch: refs/heads/master Commit: 7afa91ab97a85b7e33f3a686e4ddff42697f50b2 Parents: 016b2b9 Author: Dumindu BuddhikaAuthored: Sun Nov 15 19:12:27 2015 +0530 Committer: Dumindu Buddhika Committed: Sun Nov 15 19:12:27 2015 +0530 -- .../org/apache/phoenix/end2end/ArrayIT.java | 26 .../org/apache/phoenix/schema/PTableImpl.java | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/7afa91ab/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java index b7a2ad2..7400127 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java @@ -2679,4 +2679,30 @@ public class ArrayIT extends BaseClientManagedTimeIT { assertEquals(conn.createArrayOf("INTEGER", new Integer[]{5, 6}), rs.getArray(4)); assertEquals(3, rs.getInt(5)); } + +@Test +public void testCharPrimaryKey() throws SQLException{ +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "CREATE TABLE TEST5(testCharArray CHAR(3)[], CONSTRAINT test_pk PRIMARY KEY(testCharArray)) DEFAULT_COLUMN_FAMILY='T'"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("UPSERT INTO TEST5 VALUES (ARRAY['aaa', 'bbb', 'ccc'])"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("SELECT testCharArray from TEST5"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(conn.createArrayOf("CHAR", new String[]{"aaa", "bbb", "ccc"}), rs.getArray(1)); +} } http://git-wip-us.apache.org/repos/asf/phoenix/blob/7afa91ab/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java index b591281..ff4b512 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java @@ -579,7 +579,7 @@ public class PTableImpl implements PTable { // once we require tables to have been upgraded byteValue = StringUtil.padChar(byteValue, maxLength); } -} else if (maxLength != null && byteValue.length > maxLength) { +} else if (maxLength != null && !type.isArrayType() && byteValue.length > maxLength) { throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + SchemaUtil.toString(type, byteValue) + ")"); } os.write(byteValue, 0, byteValue.length);
phoenix git commit: PHOENIX-2301 NullPointerException when upserting into a char array column
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 a2e709642 -> 34f536252 PHOENIX-2301 NullPointerException when upserting into a char array column Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/34f53625 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/34f53625 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/34f53625 Branch: refs/heads/4.x-HBase-0.98 Commit: 34f5362526855b5752f4db153913c866f664f1e3 Parents: a2e7096 Author: Dumindu BuddhikaAuthored: Sun Nov 15 19:40:02 2015 +0530 Committer: Dumindu Buddhika Committed: Sun Nov 15 19:40:02 2015 +0530 -- .../org/apache/phoenix/end2end/ArrayIT.java | 26 .../org/apache/phoenix/schema/PTableImpl.java | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/34f53625/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java index b7a2ad2..7400127 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java @@ -2679,4 +2679,30 @@ public class ArrayIT extends BaseClientManagedTimeIT { assertEquals(conn.createArrayOf("INTEGER", new Integer[]{5, 6}), rs.getArray(4)); assertEquals(3, rs.getInt(5)); } + +@Test +public void testCharPrimaryKey() throws SQLException{ +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "CREATE TABLE TEST5(testCharArray CHAR(3)[], CONSTRAINT test_pk PRIMARY KEY(testCharArray)) DEFAULT_COLUMN_FAMILY='T'"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("UPSERT INTO TEST5 VALUES (ARRAY['aaa', 'bbb', 'ccc'])"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("SELECT testCharArray from TEST5"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(conn.createArrayOf("CHAR", new String[]{"aaa", "bbb", "ccc"}), rs.getArray(1)); +} } http://git-wip-us.apache.org/repos/asf/phoenix/blob/34f53625/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java index 0a7af1a..87e301d 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java @@ -579,7 +579,7 @@ public class PTableImpl implements PTable { // once we require tables to have been upgraded byteValue = StringUtil.padChar(byteValue, maxLength); } -} else if (maxLength != null && byteValue.length > maxLength) { +} else if (maxLength != null && !type.isArrayType() && byteValue.length > maxLength) { throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + SchemaUtil.toString(type, byteValue) + ")"); } os.write(byteValue, 0, byteValue.length);
phoenix git commit: PHOENIX-2301 NullPointerException when upserting into a char array column
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.0 fa17fc42f -> b5940dbf2 PHOENIX-2301 NullPointerException when upserting into a char array column Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b5940dbf Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b5940dbf Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b5940dbf Branch: refs/heads/4.x-HBase-1.0 Commit: b5940dbf2d0fc7072065901fb17c46139f2cd11d Parents: fa17fc4 Author: Dumindu BuddhikaAuthored: Sun Nov 15 19:43:59 2015 +0530 Committer: Dumindu Buddhika Committed: Sun Nov 15 19:43:59 2015 +0530 -- .../org/apache/phoenix/end2end/ArrayIT.java | 26 .../org/apache/phoenix/schema/PTableImpl.java | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b5940dbf/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java index b7a2ad2..7400127 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java @@ -2679,4 +2679,30 @@ public class ArrayIT extends BaseClientManagedTimeIT { assertEquals(conn.createArrayOf("INTEGER", new Integer[]{5, 6}), rs.getArray(4)); assertEquals(3, rs.getInt(5)); } + +@Test +public void testCharPrimaryKey() throws SQLException{ +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "CREATE TABLE TEST5(testCharArray CHAR(3)[], CONSTRAINT test_pk PRIMARY KEY(testCharArray)) DEFAULT_COLUMN_FAMILY='T'"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("UPSERT INTO TEST5 VALUES (ARRAY['aaa', 'bbb', 'ccc'])"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("SELECT testCharArray from TEST5"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(conn.createArrayOf("CHAR", new String[]{"aaa", "bbb", "ccc"}), rs.getArray(1)); +} } http://git-wip-us.apache.org/repos/asf/phoenix/blob/b5940dbf/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java -- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java index b591281..ff4b512 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java @@ -579,7 +579,7 @@ public class PTableImpl implements PTable { // once we require tables to have been upgraded byteValue = StringUtil.padChar(byteValue, maxLength); } -} else if (maxLength != null && byteValue.length > maxLength) { +} else if (maxLength != null && !type.isArrayType() && byteValue.length > maxLength) { throw new DataExceedsCapacityException(name.getString() + "." + column.getName().getString() + " may not exceed " + maxLength + " bytes (" + SchemaUtil.toString(type, byteValue) + ")"); } os.write(byteValue, 0, byteValue.length);
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 6cd79361c -> 1f4a5400b PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1f4a5400 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1f4a5400 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1f4a5400 Branch: refs/heads/4.x-HBase-0.98 Commit: 1f4a5400b21289216454fc11285f5c785cc4cffe Parents: 6cd7936 Author: Dumindu BuddhikaAuthored: Mon Sep 21 18:52:34 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 18:52:34 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/1f4a5400/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.0 1f2259e52 -> 3381de474 PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3381de47 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3381de47 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3381de47 Branch: refs/heads/4.x-HBase-1.0 Commit: 3381de474deb937d7b806884634bbf62f5c95619 Parents: 1f2259e Author: Dumindu BuddhikaAuthored: Mon Sep 21 19:00:21 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 19:00:21 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/3381de47/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/4.5-HBase-0.98 c1fadb10c -> 98b01546f PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/98b01546 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/98b01546 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/98b01546 Branch: refs/heads/4.5-HBase-0.98 Commit: 98b01546fd0c8a5437c0abda3ee786ea335c089a Parents: c1fadb1 Author: Dumindu BuddhikaAuthored: Mon Sep 21 19:29:04 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 19:29:04 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/98b01546/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/master 6dcc88262 -> 3c2997cda PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3c2997cd Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3c2997cd Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3c2997cd Branch: refs/heads/master Commit: 3c2997cda557cb9b6cb3bd36c67ed0b4a3f89f0e Parents: 6dcc882 Author: Dumindu BuddhikaAuthored: Mon Sep 21 16:37:50 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 16:37:50 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/3c2997cd/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/4.5-HBase-1.1 2ab807d1e -> dc594854f PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/dc594854 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/dc594854 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/dc594854 Branch: refs/heads/4.5-HBase-1.1 Commit: dc594854f87315950506be260969a3d14e76a873 Parents: 2ab807d Author: Dumindu BuddhikaAuthored: Mon Sep 21 19:36:57 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 19:36:57 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/dc594854/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =
phoenix git commit: PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL
Repository: phoenix Updated Branches: refs/heads/4.5-HBase-1.0 c35c47571 -> f7253eee6 PHOENIX-2205 Group by a divided value (e.g., time/10) returns NULL Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f7253eee Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f7253eee Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f7253eee Branch: refs/heads/4.5-HBase-1.0 Commit: f7253eee6d401aafb4cb479cc3e97d2ac017894e Parents: c35c475 Author: Dumindu BuddhikaAuthored: Mon Sep 21 19:34:59 2015 +0530 Committer: Dumindu Buddhika Committed: Mon Sep 21 19:34:59 2015 +0530 -- .../org/apache/phoenix/end2end/GroupByIT.java | 72 .../expression/RowKeyColumnExpression.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/f7253eee/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java -- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 31a55a0..51ab070 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -574,4 +574,76 @@ public class GroupByIT extends BaseQueryIT { conn.close(); } + +@Test +public void testGroupByWithIntegerDivision1() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn = DriverManager.getConnection(getUrl(), props); +ResultSet rs; +stmt = conn.prepareStatement("select time/10 as tm, hostname, avg(usage) from test1 group by hostname, tm"); +rs = stmt.executeQuery(); +assertTrue(rs.next()); +assertEquals(143985345, rs.getInt(1)); +assertEquals(4.2699, rs.getDouble(3), 0.1); +assertTrue(rs.next()); +assertEquals(143985346, rs.getInt(1)); +assertEquals(6.77, rs.getDouble(3), 0.1); +} + +@Test +public void testGroupByWithIntegerDivision2() throws Exception { +long ts = nextTimestamp(); +Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10)); +Connection conn = DriverManager.getConnection(getUrl(), props); +String ddl = "create table test1(time integer not null, hostname varchar not null,usage float,period integer constraint pk PRIMARY KEY(time, hostname))"; +conn.createStatement().execute(ddl); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30)); +conn = DriverManager.getConnection(getUrl(), props); +PreparedStatement stmt = conn.prepareStatement("upsert into test1 values(1439853462,'qa9',8.27,1439853462)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',8.27,1439853362)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853461,'qa9',5.27,1439853461)"); +stmt.execute(); +stmt = conn.prepareStatement("upsert into test1 values(1439853451,'qa9',4.27,1439853451)"); +stmt.execute(); +conn.commit(); +conn.close(); + +props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 40)); +conn =