@Description("pinot binary decimal to double")
    @ScalarFunction(value = "pinot_binary_decimal_to_double")
    @SqlNullable
    @SqlType(StandardTypes.DOUBLE)
    public static Double pinotBinaryDecimalToDouble(
            @SqlType(StandardTypes.VARBINARY) Slice input,
            @SqlType(StandardTypes.INTEGER) long bigIntegerRadix,
            @SqlType(StandardTypes.INTEGER) long scale,
            @SqlType(StandardTypes.BOOLEAN) boolean returnZeroOnNull)
    {
        if (input == null || input.getBytes().length == 0) {
            if (returnZeroOnNull) {
                return 0D;
            }
            else {
                return null;
            }
        }
        return new BigDecimal(new BigInteger(Hex.encodeHexString(input.getBytes()),
                (int) bigIntegerRadix), (int) scale).doubleValue();
    }
@Test
    public void testPinotBinaryDecimalToDouble() throws Exception
    {
        assertFunction("pinot_binary_decimal_to_double(CAST('' AS VARBINARY), 16, 18, true)", DOUBLE, 0D);
        assertFunction("pinot_binary_decimal_to_double(null, 16, 18, false)", DOUBLE, null);
        // "0DE0B6B3A7640000" = BigDecmial.ONE
        assertFunction("pinot_binary_decimal_to_double(from_hex('0DE0B6B3A7640000'), 16, 18, true)", DOUBLE, 1.0D);
    }