PDataType type = children.get(i).getDataType();
if (type == null) {
continue;
} else if (type.isCoercibleTo(PDataType.TIMESTAMP)) {
if (foundDate) {
throw new TypeMismatchException(type, node.toString());
}
if (theType == null || theType != PDataType.TIMESTAMP) {
theType = type;
}
foundDate = true;
}else if (type == PDataType.DECIMAL) {
if (theType == null || !theType.isCoercibleTo(PDataType.TIMESTAMP)) {
theType = PDataType.DECIMAL;
}
} else if (type.isCoercibleTo(PDataType.LONG)) {
if (theType == null) {
theType = PDataType.LONG;
}
} else if (type.isCoercibleTo(PDataType.DOUBLE)) {
if (theType == null) {
theType = PDataType.DOUBLE;
}
} else {
throw new TypeMismatchException(type, node.toString());
}
}
if (theType == PDataType.DECIMAL) {
return new DecimalAddExpression(children);
} else if (theType == PDataType.LONG) {
return new LongAddExpression(children);
} else if (theType == PDataType.DOUBLE) {
return new DoubleAddExpression(children);
} else if (theType == null) {
return LiteralExpression.newConstant(null, theType);
} else if (theType == PDataType.TIMESTAMP) {
return new TimestampAddExpression(children);
} else if (theType.isCoercibleTo(PDataType.DATE)) {
return new DateAddExpression(children);
} else {
throw new TypeMismatchException(theType, node.toString());
}
}
});
}