[NO ISSUE][COMP] Fix regression in RemoveRedundantVariablesRule
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Fix regression in RemoveRedundantVariablesRule introduced
by the change that added ANALYZE DATASET statement
Change-Id: I469df809115b7c419038a81c3fa1e1ae69e79c7e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/16583
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@gmail.com>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17325
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
index 32f754c..1ed7170 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/RemoveRedundantVariablesRule.java
@@ -23,7 +23,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -139,9 +138,12 @@
if (expr.getExpressionTag() != LogicalExpressionTag.VARIABLE) {
continue;
}
- VariableReferenceExpression rhsVarRefExpr = (VariableReferenceExpression) expr;
- // Update equivalence class map.
LogicalVariable lhs = assignOp.getVariables().get(i);
+ if (context.shouldNotBeInlined(lhs)) {
+ continue;
+ }
+ // Update equivalence class map.
+ VariableReferenceExpression rhsVarRefExpr = (VariableReferenceExpression) expr;
LogicalVariable rhs = rhsVarRefExpr.getVariableReference();
updateEquivalenceClassMap(lhs, rhs);
}
@@ -159,7 +161,6 @@
modified = true;
}
} else {
- substVisitor.reset(context);
if (op.acceptExpressionTransform(substVisitor)) {
modified = true;
}
@@ -284,13 +285,6 @@
}
private class VariableSubstitutionVisitor implements ILogicalExpressionReferenceTransform {
-
- private IOptimizationContext context;
-
- void reset(IOptimizationContext context) {
- this.context = Objects.requireNonNull(context);
- }
-
@Override
public boolean transform(Mutable<ILogicalExpression> exprRef) {
ILogicalExpression e = exprRef.getValue();
@@ -299,9 +293,6 @@
// Replace variable references with their equivalent representative in the equivalence class map.
VariableReferenceExpression varRefExpr = (VariableReferenceExpression) e;
LogicalVariable var = varRefExpr.getVariableReference();
- if (context.shouldNotBeInlined(var)) {
- return false;
- }
LogicalVariable representative = findEquivalentRepresentativeVar(var);
if (representative != null) {
varRefExpr.setVariable(representative);