ASTERIXDB-1204: fixed LIMIT pushdown into join
- Fixed PushMapOperatorDownThroughProductRule not to pushdown LIMIT into a JOIN operator
Change-Id: I19e73c8d444ac0c8ecfcdf3ad3ebe744d6c8d0df
Reviewed-on: https://asterix-gerrit.ics.uci.edu/632
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushMapOperatorDownThroughProductRule.java b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushMapOperatorDownThroughProductRule.java
index 1c9b8d8..f956d73 100644
--- a/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushMapOperatorDownThroughProductRule.java
+++ b/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushMapOperatorDownThroughProductRule.java
@@ -22,7 +22,6 @@
import java.util.List;
import org.apache.commons.lang3.mutable.Mutable;
-
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext;
@@ -37,7 +36,8 @@
public class PushMapOperatorDownThroughProductRule implements IAlgebraicRewriteRule {
@Override
- public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
+ public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+ throws AlgebricksException {
return false;
}
@@ -45,7 +45,9 @@
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
throws AlgebricksException {
AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
- if (!op1.isMap()) {
+ // Even the LIMIT operator is a map operator, we don't push LIMIT operator into a join
+ // since a new LIMIT under a join can't generate the original result.
+ if (!op1.isMap() || op1.getOperatorTag() == LogicalOperatorTag.LIMIT) {
return false;
}
Mutable<ILogicalOperator> op2Ref = op1.getInputs().get(0);