Reintegrated asterix_unnest_to_join_enhance.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@538 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
index f065c3e..76039ab 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
@@ -50,6 +50,7 @@
import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.BreakSelectIntoConjunctsRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.ComplexJoinInferenceRule;
+import edu.uci.ics.hyracks.algebricks.rewriter.rules.ComplexUnnestToProductRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.ConsolidateAssignsRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.ConsolidateSelectsRule;
import edu.uci.ics.hyracks.algebricks.rewriter.rules.EliminateSubplanRule;
@@ -119,6 +120,7 @@
condPushDownAndJoinInference.add(new PushDieUpRule());
condPushDownAndJoinInference.add(new RemoveRedundantListifyRule());
condPushDownAndJoinInference.add(new SimpleUnnestToProductRule());
+ condPushDownAndJoinInference.add(new ComplexUnnestToProductRule());
condPushDownAndJoinInference.add(new ComplexJoinInferenceRule());
condPushDownAndJoinInference.add(new PushSelectIntoJoinRule());
condPushDownAndJoinInference.add(new IntroJoinInsideSubplanRule());
diff --git a/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_01.aql b/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_01.aql
new file mode 100644
index 0000000..85ee87a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_01.aql
@@ -0,0 +1,15 @@
+/*
+ * Description : Tests that non-datascan unnests are rewritten into joins.
+ * Success : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/unnest-to-join_01.adm";
+
+for $x in [1,2,3,4,5,6]
+for $y in [4,5,6,7,8,9]
+where $x = $y
+return $y
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_02.aql b/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_02.aql
new file mode 100644
index 0000000..2402eb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/unnest-to-join_02.aql
@@ -0,0 +1,12 @@
+/*
+ * Description : Tests that non-datascan unnests in a subplan are rewritten into joins.
+ * Success : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/unnest-to-join_02.adm";
+
+some $x in [1,2,3,4,5,6], $y in [4,5,6,7,8,9] satisfies $x = $y
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_01.plan b/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_01.plan
new file mode 100644
index 0000000..d43cc94
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_01.plan
@@ -0,0 +1,10 @@
+-- SINK_WRITE |UNPARTITIONED|
+ -- STREAM_PROJECT |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- HYBRID_HASH_JOIN [$$0][$$1] |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_02.plan b/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_02.plan
new file mode 100644
index 0000000..bfb15c7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/results/unnest-to-join_02.plan
@@ -0,0 +1,21 @@
+-- SINK_WRITE |UNPARTITIONED|
+ -- STREAM_PROJECT |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- PRE_CLUSTERED_GROUP_BY[$$8] |UNPARTITIONED|
+ {
+ -- AGGREGATE |UNPARTITIONED|
+ -- NESTED_TUPLE_SOURCE |UNPARTITIONED|
+ }
+ -- ONE_TO_ONE_EXCHANGE |LOCAL|
+ -- STABLE_SORT [$$8(ASC)] |LOCAL|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- STREAM_PROJECT |UNPARTITIONED|
+ -- ASSIGN |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- HYBRID_HASH_JOIN [$$0][$$1] |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|
+ -- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
+ -- UNNEST |UNPARTITIONED|
+ -- EMPTY_TUPLE_SOURCE |UNPARTITIONED|