Datum valueDatum = params.get(0);
if(valueDatum instanceof NullDatum) {
return NullDatum.get();
}
double value = valueDatum.asFloat8();
// Note: there are various round up/down approaches (https://en.wikipedia.org/wiki/Rounding#Tie-breaking).
// Math.round uses an approach different from other programming languages, so the results of round function
// can be different from other DBMSs. For example, Math.round(-5.5) returns -5. In contrast,
// round function in MySQL and PostgreSQL returns -6. The below code is a workaround code for this.