fix issue273
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
index 3f96b8e..e494ef4 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
@@ -103,16 +103,16 @@
IVariableTypeEnvironment env = insertDeleteOperator.computeOutputTypeEnvironment(context);
IAType inputRecordType = (IAType) env.getVarType(recordVar);
- // the input record type can be an union type -- for the case when it comes from a subplan or left-outer join
+ /** the input record type can be an union type -- for the case when it comes from a subplan or left-outer join */
boolean checkNull = false;
while (isOptional(inputRecordType)) {
- //while-loop for the case there is a nested multi-level union
+ /** while-loop for the case there is a nested multi-level union */
inputRecordType = ((AUnionType) inputRecordType).getUnionList().get(
NonTaggedFormatUtil.OPTIONAL_TYPE_INDEX_IN_UNION_LIST);
checkNull = true;
}
- //see whether the input record type needs to be casted
+ /** see whether the input record type needs to be casted */
boolean cast = !compatible(requiredRecordType, inputRecordType);
if (checkNull) {
@@ -149,20 +149,20 @@
Mutable<ILogicalOperator> opRef = opRefs.get(index);
ILogicalOperator op = opRef.getValue();
- //get produced vars
+ /** get produced vars */
List<LogicalVariable> producedVars = new ArrayList<LogicalVariable>();
VariableUtilities.getProducedVariables(op, producedVars);
IVariableTypeEnvironment env = op.computeOutputTypeEnvironment(context);
for (int i = 0; i < producedVars.size(); i++) {
LogicalVariable var = producedVars.get(i);
if (var.equals(recordVar)) {
- //insert an assign operator to call the function on-top-of the variable
+ /** insert an assign operator to call the function on-top-of the variable */
IAType actualType = (IAType) env.getVarType(var);
AbstractFunctionCallExpression cast = new ScalarFunctionCallExpression(
FunctionUtils.getFunctionInfo(fd));
cast.getArguments()
.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
- //enforce the required record type
+ /** enforce the required record type */
TypeComputerUtilities.setRequiredAndInputTypes(cast, requiredRecordType, actualType);
LogicalVariable newAssignVar = context.newVar();
AssignOperator newAssignOperator = new AssignOperator(newAssignVar,
@@ -175,10 +175,10 @@
return newAssignVar;
}
}
- //recursive descend to the operator who produced the recordVar
+ /** recursive descend to the operator who produced the recordVar */
LogicalVariable replacedVar = addWrapperFunction(requiredRecordType, recordVar, op, context, fd);
if (replacedVar != null) {
- //substitute the recordVar by the replacedVar for operators who uses recordVar
+ /** substitute the recordVar by the replacedVar for operators who uses recordVar */
VariableUtilities.substituteVariables(parent, recordVar, replacedVar, context);
return replacedVar;
}
@@ -222,7 +222,7 @@
IAType inputTypeInside = inputTypes[i];
if (isOptional(inputTypes[i])) {
if (!isOptional(reqTypes[i])) {
- // if the required type is not optional, the two types are incompatible
+ /** if the required type is not optional, the two types are incompatible */
return false;
}
inputTypeInside = ((AUnionType) inputTypes[i]).getUnionList().get(
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
index e72c202..d6e0f42 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
@@ -341,8 +341,8 @@
}
// the input has extra fields
if (!matched && !reqType.isOpen()) {
- throw new AlgebricksException("static type mismatch: including an extra closed field " + fieldName
- + " of type " + fieldType);
+ throw new AlgebricksException("static type mismatch: the input record includes an extra closed field "
+ + fieldName + ":" + fieldType + "! Please check the field name and type.");
}
}
@@ -390,7 +390,9 @@
//if the input type is open, return false, give that to dynamic type cast to defer the error to the runtime
return false;
} else {
- throw new AlgebricksException("static type mismatch: miss a required closed field " + reqFieldName);
+ throw new AlgebricksException(
+ "static type mismatch: the input record misses a required closed field " + reqFieldName
+ + ":" + reqFieldType + "! Please check the field name and type.");
}
}
}