[ASTERIXDB-2405][COMP] Allow IntroduceJoin to start at delegates

- user model changes: no
- storage format changes: no
- interface changes: no

details:
Previously, IntroduceJoinAccessMethodRule would only start at
the top of a plan (commit or distribute result)
Commit is the only delegate operator in master.
We have one more delegate operator in BAD, which is also the
top of the plan.
This change allows all delegates to be considered by
IntroduceJoinAccessMethodRule as a starting point.

Change-Id: I00172958df8c9ce6dc4cc6b405bc1d6665e2d514
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2740
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Xikui Wang <xkkwww@gmail.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
index 401ea23..bc73199 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
@@ -24,7 +24,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.asterix.algebra.operators.CommitOperator;
 import org.apache.asterix.metadata.entities.Dataset;
 import org.apache.asterix.metadata.entities.Index;
 import org.apache.commons.lang3.mutable.Mutable;
@@ -41,7 +40,6 @@
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
-import org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.InnerJoinOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.LeftOuterJoinOperator;
@@ -127,11 +125,6 @@
             return false;
         }
 
-        if (op.getOperatorTag() == LogicalOperatorTag.DELEGATE_OPERATOR
-                && !(((DelegateOperator) op).getDelegate() instanceof CommitOperator)) {
-            return false;
-        }
-
         afterJoinRefs = new ArrayList<>();
         // Recursively checks the given plan whether the desired pattern exists in it.
         // If so, try to optimize the plan.