}
};
private static PDatum inferBindDatum(List<Expression> children) {
boolean isChildTypeUnknown = false;
PDatum datum = children.get(1);
for (int i = 2; i < children.size(); i++) {
Expression child = children.get(i);
PDataType childType = child.getDataType();
if (childType == null) {
isChildTypeUnknown = true;
} else if (datum.getDataType() == null) {
datum = child;
isChildTypeUnknown = true;
} else if (datum.getDataType() == childType || childType.isCoercibleTo(datum.getDataType())) {
continue;
} else if (datum.getDataType().isCoercibleTo(childType)) {
datum = child;
}
}
// If we found an "unknown" child type and the return type is a number
// make the return type be the most general number type of DECIMAL.
// TODO: same for TIMESTAMP for DATE/TIME?
if (isChildTypeUnknown && datum.getDataType() != null && datum.getDataType().isCoercibleTo(PDataType.DECIMAL)) {
return DECIMAL_DATUM;
}
return datum;
}