throw new SemanticException(generateErrorMessage(tabref,
"Schema of both sides of union should match. " + leftalias
+ " does not have the field " + field));
}
if (!lInfo.getInternalName().equals(rInfo.getInternalName())) {
throw new OptiqSemanticException(generateErrorMessage(tabref,
"Schema of both sides of union should match: field " + field + ":"
+ " appears on the left side of the UNION at column position: "
+ getPositionFromInternalName(lInfo.getInternalName())
+ ", and on the right side of the UNION at column position: "
+ getPositionFromInternalName(rInfo.getInternalName())
+ ". Column positions should match for a UNION"));
}
// try widening coversion, otherwise fail union
TypeInfo commonTypeInfo = FunctionRegistry.getCommonClassForUnionAll(lInfo.getType(),
rInfo.getType());
if (commonTypeInfo == null) {
throw new OptiqSemanticException(generateErrorMessage(tabref,
"Schema of both sides of union should match: Column " + field + " is of type "
+ lInfo.getType().getTypeName() + " on first table and type "
+ rInfo.getType().getTypeName() + " on second table"));
}
}