Repository: phoenix
Updated Branches:
  refs/heads/calcite f2d95da77 -> 59d05d3a2


PHOENIX-1843 Implement getCollations() in PhoenixTable.getStatistics() and all 
other PhoenixRel nodes


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

Branch: refs/heads/calcite
Commit: 59d05d3a2685821f67124b7e407394354c4d9cc3
Parents: f2d95da
Author: maryannxue <[email protected]>
Authored: Wed Jun 10 21:02:02 2015 -0400
Committer: maryannxue <[email protected]>
Committed: Wed Jun 10 21:02:02 2015 -0400

----------------------------------------------------------------------
 .../org/apache/phoenix/calcite/CalciteTest.java | 28 ++++++++++++++++++++
 .../calcite/metadata/PhoenixRelMdCollation.java |  4 +--
 2 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/59d05d3a/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 dca783d..2774aa1 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
@@ -360,6 +360,34 @@ public class CalciteTest extends BaseClientManagedTimeIT {
                 .close();
     }
     
+    @Test public void testJoinPlanningWithCollation() throws Exception { 
+        // Server-join with LHS sorted on order-by fields
+        start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", 
supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + 
JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = 
supp.\"supplier_id\" order by supp.\"supplier_id\"")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixToClientConverter\n" +
+                           "    PhoenixPostJoinProject(item_id=[$2], 
NAME=[$3], supplier_id=[$0], NAME0=[$1])\n" +
+                           "      PhoenixServerJoin(condition=[=($4, $0)], 
joinType=[inner])\n" +
+                           "        PhoenixServerProject(supplier_id=[$0], 
NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, 
SupplierTable]])\n" +
+                           "        PhoenixToClientConverter\n" +
+                           "          PhoenixServerProject(item_id=[$0], 
NAME=[$1], supplier_id=[$5])\n" +
+                           "            PhoenixTableScan(table=[[phoenix, 
Join, ItemTable]])\n")
+                .close();
+        
+        // Join key being order-by fields with the other side sorted on 
order-by fields
+        start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", 
supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item JOIN " + 
JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = 
supp.\"supplier_id\" order by item.\"supplier_id\"")
+                .explainIs("PhoenixToEnumerableConverter\n" +
+                           "  PhoenixClientProject(item_id=[$0], NAME=[$1], 
supplier_id=[$3], NAME0=[$4])\n" +
+                           "    PhoenixClientJoin(condition=[=($2, $3)], 
joinType=[inner])\n" +
+                           "      PhoenixServerSort(sort0=[$2], dir0=[ASC])\n" 
+
+                           "        PhoenixServerProject(item_id=[$0], 
NAME=[$1], supplier_id=[$5])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, 
ItemTable]])\n" +
+                           "      PhoenixToClientConverter\n" +
+                           "        PhoenixServerProject(supplier_id=[$0], 
NAME=[$1])\n" +
+                           "          PhoenixTableScan(table=[[phoenix, Join, 
SupplierTable]])\n")
+                .close();
+    }
+    
     @Test public void testMultiJoin() throws Exception {
         start().sql("select t1.entity_id, t2.a_string, t3.organization_id from 
aTable t1 join aTable t2 on t1.entity_id = t2.entity_id and t1.organization_id 
= t2.organization_id join atable t3 on t1.entity_id = t3.entity_id and 
t1.organization_id = t3.organization_id where t1.a_string = 'a'") 
                 .explainIs("PhoenixToEnumerableConverter\n" +

http://git-wip-us.apache.org/repos/asf/phoenix/blob/59d05d3a/phoenix-core/src/main/java/org/apache/phoenix/calcite/metadata/PhoenixRelMdCollation.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/metadata/PhoenixRelMdCollation.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/metadata/PhoenixRelMdCollation.java
index 53c273b..821d7b9 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/metadata/PhoenixRelMdCollation.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/metadata/PhoenixRelMdCollation.java
@@ -39,9 +39,7 @@ public class PhoenixRelMdCollation {
     
     /** Helper method to determine a {@link PhoenixServerJoin}'s collation. */
     public static List<RelCollation> hashJoin(RelNode left, RelNode right, 
JoinRelType joinType) {
-        // TODO enable the following code, right now would cause some 
unexpected behaviors.
-        // return RelMetadataQuery.collations(left);
-        return ImmutableList.of();
+        return RelMetadataQuery.collations(left);
     }
 
     public static List<RelCollation> mergeJoin(RelNode left, RelNode right,

Reply via email to