all tests work
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
index c63b0d2..a07583f 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
@@ -20,6 +20,7 @@
import org.apache.commons.lang3.mutable.Mutable;
+import edu.uci.ics.asterix.om.typecomputer.base.TypeComputerUtilities;
import edu.uci.ics.asterix.om.types.IAType;
import edu.uci.ics.asterix.optimizer.rules.typecast.StaticTypeCastUtil;
import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -52,26 +53,26 @@
throws AlgebricksException {
if (context.checkIfInDontApplySet(this, opRef.getValue()))
return false;
- AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
+ AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
context.addToDontApplySet(this, opRef.getValue());
/**
* rewrite list constructor types for list constructor functions
*/
List<Mutable<ILogicalExpression>> expressions;
- switch (op1.getOperatorTag()) {
+ switch (op.getOperatorTag()) {
case ASSIGN:
- AbstractAssignOperator assignOp = (AbstractAssignOperator) op1;
+ AbstractAssignOperator assignOp = (AbstractAssignOperator) op;
expressions = assignOp.getExpressions();
break;
case UNNEST:
- AbstractUnnestOperator unnestOp = (AbstractUnnestOperator) op1;
+ AbstractUnnestOperator unnestOp = (AbstractUnnestOperator) op;
expressions = Collections.singletonList(unnestOp.getExpressionRef());
break;
default:
return false;
}
- IVariableTypeEnvironment env = op1.computeOutputTypeEnvironment(context);
+ IVariableTypeEnvironment env = op.computeOutputTypeEnvironment(context);
return rewriteExpressions(expressions, env);
}
@@ -83,7 +84,10 @@
if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
AbstractFunctionCallExpression argFuncExpr = (AbstractFunctionCallExpression) expr;
IAType exprType = (IAType) env.getType(argFuncExpr);
- changed = StaticTypeCastUtil.rewriteListExpr(argFuncExpr, exprType, exprType, env) || changed;
+ if (StaticTypeCastUtil.rewriteListExpr(argFuncExpr, exprType, exprType, env)) {
+ TypeComputerUtilities.resetRequiredAndInputTypes(argFuncExpr);
+ changed = true;
+ }
}
}
return changed;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
index 2c7ff10..84d177f 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/typecomputer/base/TypeComputerUtilities.java
@@ -23,9 +23,9 @@
public static boolean setRequiredAndInputTypes(AbstractFunctionCallExpression expr, IAType requiredRecordType,
IAType inputRecordType) {
boolean changed = false;
- Object opaqueParameter = expr.getOpaqueParameters();
- if (opaqueParameter == null) {
- Object[] opaqueParameters = new Object[2];
+ Object[] opaqueParameters = expr.getOpaqueParameters();
+ if (opaqueParameters == null) {
+ opaqueParameters = new Object[2];
opaqueParameters[0] = requiredRecordType;
opaqueParameters[1] = inputRecordType;
expr.setOpaqueParameters(opaqueParameters);
@@ -34,6 +34,10 @@
return changed;
}
+ public static void resetRequiredAndInputTypes(AbstractFunctionCallExpression expr) {
+ expr.setOpaqueParameters(null);
+ }
+
public static IAType getRequiredType(AbstractFunctionCallExpression expr) {
Object[] type = expr.getOpaqueParameters();
if (type != null) {