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 2015/04/03 19:23:30 UTC

phoenix git commit: Passed one subquery

Repository: phoenix
Updated Branches:
  refs/heads/calcite f6ff11710 -> fbcefdbf3


Passed one subquery


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

Branch: refs/heads/calcite
Commit: fbcefdbf38208c632297f274fcf8301d76180234
Parents: f6ff117
Author: maryannxue <we...@intel.com>
Authored: Fri Apr 3 13:23:16 2015 -0400
Committer: maryannxue <we...@intel.com>
Committed: Fri Apr 3 13:23:16 2015 -0400

----------------------------------------------------------------------
 .../src/it/java/org/apache/phoenix/calcite/CalciteTest.java | 9 +++++++--
 .../main/java/org/apache/phoenix/calcite/CalciteUtils.java  | 8 ++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/fbcefdbf/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
index f9e00ce..a4017dc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
@@ -336,9 +336,9 @@ public class CalciteTest extends BaseClientManagedTimeIT {
     }
     
     @Test public void testSubquery() {
-        start().sql("SELECT \"order_id\" FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o WHERE quantity = (SELECT max(quantity) FROM " + JOIN_ORDER_TABLE_FULL_NAME + " q WHERE o.\"item_id\" = q.\"item_id\")")
+        start().sql("SELECT \"order_id\", quantity FROM " + JOIN_ORDER_TABLE_FULL_NAME + " o WHERE quantity = (SELECT max(quantity) FROM " + JOIN_ORDER_TABLE_FULL_NAME + " q WHERE o.\"item_id\" = q.\"item_id\")")
                .explainIs("PhoenixToEnumerableConverter\n" +
-                          "  PhoenixProject(order_id=[$0])\n" +
+                          "  PhoenixProject(order_id=[$0], QUANTITY=[$4])\n" +
                           "    PhoenixJoin(condition=[AND(=($2, $6), =($4, $7))], joinType=[inner])\n" +
                           "      PhoenixTableScan(table=[[phoenix, ORDERTABLE]])\n" +
                           "      PhoenixAggregate(group=[{0}], EXPR$0=[MAX($1)])\n" +
@@ -348,6 +348,11 @@ public class CalciteTest extends BaseClientManagedTimeIT {
                           "            PhoenixAggregate(group=[{0}])\n" +
                           "              PhoenixProject(item_id=[$2])\n" +
                           "                PhoenixTableScan(table=[[phoenix, ORDERTABLE]])\n")
+               .resultIs(new Object[][]{
+                         {"000000000000001", 1000},
+                         {"000000000000003", 3000},
+                         {"000000000000004", 4000},
+                         {"000000000000005", 5000}})
                .close();
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/fbcefdbf/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
index 8146d6d..4110b5e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/CalciteUtils.java
@@ -22,6 +22,7 @@ import org.apache.phoenix.expression.LiteralExpression;
 import org.apache.phoenix.expression.function.AggregateFunction;
 import org.apache.phoenix.expression.function.CountAggregateFunction;
 import org.apache.phoenix.expression.function.FunctionExpression;
+import org.apache.phoenix.expression.function.MaxAggregateFunction;
 import org.apache.phoenix.expression.function.SumAggregateFunction;
 
 import com.google.common.collect.Lists;
@@ -129,6 +130,13 @@ public class CalciteUtils {
                 return new SumAggregateFunction(args);
             }
         });
+        FUNCTION_MAP.put("MAX", new FunctionFactory() {
+            @Override
+            public FunctionExpression newFunction(SqlFunction sqlFunc,
+                    List<Expression> args) {
+                return new MaxAggregateFunction(args, null);
+            }
+        });
     }
 
 	static Expression toExpression(RexNode node, Implementor implementor) {