PHOENIX-2279 Error result when there are both GROUP-BY and LIMIT operation on 
derived table


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

Branch: refs/heads/calcite
Commit: e2b6009f24b0b1019eb7cfaceea593556befb2cb
Parents: 551cc7d
Author: maryannxue <maryann....@gmail.com>
Authored: Mon Jan 25 21:26:09 2016 -0500
Committer: maryannxue <maryann....@gmail.com>
Committed: Mon Jan 25 21:26:09 2016 -0500

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/DerivedTableIT.java     | 13 +++++++++++++
 .../apache/phoenix/execute/ClientAggregatePlan.java    |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e2b6009f/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
index 223a0e5..151ce3e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
@@ -528,6 +528,19 @@ public class DerivedTableIT extends 
BaseClientManagedTimeIT {
             assertEquals(10,rs.getInt(2));
 
             assertFalse(rs.next());
+            
+            // (union) groupby limit
+            query = "SELECT a_string, count(*) FROM (SELECT a_string FROM 
aTable where a_byte < 4 union all SELECT a_string FROM aTable where a_byte > 8) 
group by a_string limit 2";
+            statement = conn.prepareStatement(query);
+            rs = statement.executeQuery();
+            assertTrue (rs.next());
+            assertEquals(A_VALUE,rs.getString(1));
+            assertEquals(3,rs.getInt(2));
+            assertTrue (rs.next());
+            assertEquals(C_VALUE,rs.getString(1));
+            assertEquals(1,rs.getInt(2));
+
+            assertFalse(rs.next());            
         } finally {
             conn.close();
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e2b6009f/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
index 3df0447..c1ef67d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
@@ -100,7 +100,7 @@ public class ClientAggregatePlan extends 
ClientProcessingPlan {
                 for (Expression keyExpression : keyExpressions) {
                     keyExpressionOrderBy.add(new 
OrderByExpression(keyExpression, false, true));
                 }
-                iterator = new OrderedResultIterator(iterator, 
keyExpressionOrderBy, thresholdBytes, limit, 
projector.getEstimatedRowByteSize());
+                iterator = new OrderedResultIterator(iterator, 
keyExpressionOrderBy, thresholdBytes, null, 
projector.getEstimatedRowByteSize());
             }
             aggResultIterator = new 
ClientGroupedAggregatingResultIterator(LookAheadResultIterator.wrap(iterator), 
serverAggregators, groupBy.getKeyExpressions());
             aggResultIterator = new 
GroupedAggregatingResultIterator(LookAheadResultIterator.wrap(aggResultIterator),
 clientAggregators);

Reply via email to