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/06/11 23:40:19 UTC
phoenix git commit: PHOENIX-1839 Enable hash-join with RIGHT OUTER
joins
Repository: phoenix
Updated Branches:
refs/heads/calcite 2e5a91875 -> 171cc9249
PHOENIX-1839 Enable hash-join with RIGHT OUTER joins
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/171cc924
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/171cc924
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/171cc924
Branch: refs/heads/calcite
Commit: 171cc92490ac405813c8809b82cac72ead64c5be
Parents: 2e5a918
Author: maryannxue <we...@intel.com>
Authored: Thu Jun 11 17:40:11 2015 -0400
Committer: maryannxue <we...@intel.com>
Committed: Thu Jun 11 17:40:11 2015 -0400
----------------------------------------------------------------------
.../org/apache/phoenix/calcite/CalciteTest.java | 23 ++++++++++++++++++++
.../calcite/jdbc/PhoenixPrepareImpl.java | 5 +++++
2 files changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/171cc924/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 96c3d96..7ce4f49 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
@@ -313,6 +313,29 @@ public class CalciteTest extends BaseClientManagedTimeIT {
.close();
}
+ @Test public void testRightOuterJoin() throws Exception {
+ start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item RIGHT OUTER JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = 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=[left])\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")
+ .resultIs(new Object[][] {
+ {"0000000001", "T1", "0000000001", "S1"},
+ {"0000000002", "T2", "0000000001", "S1"},
+ {"0000000003", "T3", "0000000002", "S2"},
+ {"0000000004", "T4", "0000000002", "S2"},
+ {null, null, "0000000003", "S3"},
+ {null, null, "0000000004", "S4"},
+ {"0000000005", "T5", "0000000005", "S5"},
+ {"0000000006", "T6", "0000000006", "S6"}})
+ .close();
+ }
+
@Test public void testClientJoin() throws Exception {
start().sql("SELECT item.\"item_id\", item.name, supp.\"supplier_id\", supp.name FROM " + JOIN_ITEM_TABLE_FULL_NAME + " item FULL OUTER JOIN " + JOIN_SUPPLIER_TABLE_FULL_NAME + " supp ON item.\"supplier_id\" = supp.\"supplier_id\" order by \"item_id\", supp.name")
.explainIs("PhoenixToEnumerableConverter\n" +
http://git-wip-us.apache.org/repos/asf/phoenix/blob/171cc924/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
index 20e1943..01a8c7b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixPrepareImpl.java
@@ -5,6 +5,7 @@ import org.apache.calcite.plan.RelOptCostFactory;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.apache.calcite.rel.rules.JoinCommuteRule;
import org.apache.phoenix.calcite.rules.PhoenixAddScanLimitRule;
import org.apache.phoenix.calcite.rules.PhoenixCompactClientSortRule;
import org.apache.phoenix.calcite.rules.PhoenixConverterRules;
@@ -24,6 +25,10 @@ public class PhoenixPrepareImpl extends CalcitePrepareImpl {
org.apache.calcite.plan.Context externalContext,
RelOptCostFactory costFactory) {
RelOptPlanner planner = super.createPlanner(prepareContext, externalContext, costFactory);
+
+ planner.removeRule(JoinCommuteRule.INSTANCE);
+ planner.addRule(JoinCommuteRule.SWAP_OUTER);
+
RelOptRule[] rules = PhoenixConverterRules.RULES;
for (RelOptRule rule : rules) {
planner.addRule(rule);