ASTERIXDB-1359 Removed Project from IntroduceSecondaryIndex Rule

Change-Id: I912e3d56c0b9c2b5b252630acf8b15c54e0f61a1
Reviewed-on: https://asterix-gerrit.ics.uci.edu/742
Reviewed-by: Ildar Absalyamov <ildar.absalyamov@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
index 8cc18ba..8487374 100644
--- a/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
+++ b/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
@@ -21,10 +21,8 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Set;
 import java.util.Stack;
 
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
@@ -75,10 +73,8 @@
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.IndexInsertDeleteUpsertOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteUpsertOperator.Kind;
-import org.apache.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.ReplicateOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.TokenizeOperator;
-import org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
 import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
 
 public class IntroduceSecondaryIndexInsertDeleteRule implements IAlgebraicRewriteRule {
@@ -260,22 +256,6 @@
                 throw new AlgebricksException(e);
             }
         }
-        Set<LogicalVariable> projectVars = new HashSet<LogicalVariable>();
-        VariableUtilities.getUsedVariables(op1, projectVars);
-        if (enforcedRecordVar != null) {
-            projectVars.add(enforcedRecordVar);
-        }
-        if (insertOp.getOperation() == Kind.UPSERT) {
-            projectVars.add(insertOp.getPrevRecordVar());
-            if (filteringFields != null) {
-                // project prev filter value
-                projectVars.add(insertOp.getPrevFilterVar());
-            }
-        }
-        ProjectOperator project = new ProjectOperator(new ArrayList<LogicalVariable>(projectVars));
-        project.getInputs().add(new MutableObject<ILogicalOperator>(currentTop));
-        context.computeAndSetTypeEnvironmentForOperator(project);
-        currentTop = project;
 
         // Replicate Operator is applied only when doing the bulk-load.
         AbstractLogicalOperator replicateOp = null;
diff --git a/asterix-app/src/test/resources/optimizerts/results/disjunction-to-join-delete-3.plan b/asterix-app/src/test/resources/optimizerts/results/disjunction-to-join-delete-3.plan
index bca0381..7d38039 100644
--- a/asterix-app/src/test/resources/optimizerts/results/disjunction-to-join-delete-3.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/disjunction-to-join-delete-3.plan
@@ -9,7 +9,7 @@
                 -- INSERT_DELETE  |PARTITIONED|
                   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                     -- MATERIALIZE  |PARTITIONED|
-                      -- HASH_PARTITION_EXCHANGE [$$8]  |PARTITIONED|
+                      -- HASH_PARTITION_EXCHANGE [$$10]  |PARTITIONED|
                         -- ASSIGN  |PARTITIONED|
                           -- STREAM_PROJECT  |PARTITIONED|
                             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
@@ -18,8 +18,8 @@
                                   -- UNNEST  |UNPARTITIONED|
                                     -- EMPTY_TUPLE_SOURCE  |UNPARTITIONED|
                                 -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
-                                  -- ASSIGN  |PARTITIONED|
-                                    -- STREAM_PROJECT  |PARTITIONED|
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    -- ASSIGN  |PARTITIONED|
                                       -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                         -- DATASOURCE_SCAN  |PARTITIONED|
                                           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|