Search in sources :

Example 1 with DecimalParseResult

use of com.facebook.presto.common.type.DecimalParseResult in project presto by prestodb.

the class AbstractTestFunctions method decimal.

protected static SqlDecimal decimal(String decimalString) {
    DecimalParseResult parseResult = Decimals.parseIncludeLeadingZerosInPrecision(decimalString);
    BigInteger unscaledValue;
    if (parseResult.getType().isShort()) {
        unscaledValue = BigInteger.valueOf((Long) parseResult.getObject());
    } else {
        unscaledValue = Decimals.decodeUnscaledValue((Slice) parseResult.getObject());
    }
    return new SqlDecimal(unscaledValue, parseResult.getType().getPrecision(), parseResult.getType().getScale());
}
Also used : Slice(io.airlift.slice.Slice) DecimalParseResult(com.facebook.presto.common.type.DecimalParseResult) BigInteger(java.math.BigInteger) SqlDecimal(com.facebook.presto.common.type.SqlDecimal)

Example 2 with DecimalParseResult

use of com.facebook.presto.common.type.DecimalParseResult in project urban-eureka by errir503.

the class AbstractTestFunctions method decimal.

protected static SqlDecimal decimal(String decimalString) {
    DecimalParseResult parseResult = Decimals.parseIncludeLeadingZerosInPrecision(decimalString);
    BigInteger unscaledValue;
    if (parseResult.getType().isShort()) {
        unscaledValue = BigInteger.valueOf((Long) parseResult.getObject());
    } else {
        unscaledValue = Decimals.decodeUnscaledValue((Slice) parseResult.getObject());
    }
    return new SqlDecimal(unscaledValue, parseResult.getType().getPrecision(), parseResult.getType().getScale());
}
Also used : Slice(io.airlift.slice.Slice) DecimalParseResult(com.facebook.presto.common.type.DecimalParseResult) BigInteger(java.math.BigInteger) SqlDecimal(com.facebook.presto.common.type.SqlDecimal)

Aggregations

DecimalParseResult (com.facebook.presto.common.type.DecimalParseResult)2 SqlDecimal (com.facebook.presto.common.type.SqlDecimal)2 Slice (io.airlift.slice.Slice)2 BigInteger (java.math.BigInteger)2