Example #1
0
 @ScalarOperator(CAST)
 @SqlType(StandardTypes.TINYINT)
 public static long castToTinyint(@SqlType(StandardTypes.DOUBLE) double value) {
   try {
     return SignedBytes.checkedCast((long) MathFunctions.round(value));
   } catch (IllegalArgumentException e) {
     throw new PrestoException(
         NUMERIC_VALUE_OUT_OF_RANGE, "Out of range for tinyint: " + value, e);
   }
 }
Example #2
0
 @ScalarOperator(CAST)
 @SqlType(StandardTypes.BIGINT)
 public static long castToLong(@SqlType(StandardTypes.DOUBLE) double value) {
   return (long) MathFunctions.round(value);
 }