presto-phoenix/src/main/java/io/prestosql/plugin/phoenix/TypeUtils.java/TypeUtils/jdbcObjectToPrestoNative
class TypeUtils:    private static Object jdbcObjectToPrestoNative(ConnectorSession session, Object jdbcObject, Type prestoType)
    {
        if (jdbcObject == null) {
            return null;
        }

        if (BOOLEAN.equals(prestoType)
                || TINYINT.equals(prestoType)
                || SMALLINT.equals(prestoType)
                || INTEGER.equals(prestoType)
                || BIGINT.equals(prestoType)
                || DOUBLE.equals(prestoType)) {
            return jdbcObject;
        }

        if (prestoType instanceof ArrayType) {
            return jdbcObjectArrayToBlock(session, ((ArrayType) prestoType).getElementType(), (Object[]) jdbcObject);
        }

        if (prestoType instanceof DecimalType) {
            DecimalType decimalType = (DecimalType) prestoType;
            BigDecimal value = (BigDecimal) jdbcObject;
            if (decimalType.isShort()) {
                return encodeShortScaledValue(value, decimalType.getScale());
            }
            return encodeScaledValue(value, decimalType.getScale());
        }

        if (REAL.equals(prestoType)) {
            return floatToRawIntBits((float) jdbcObject);
        }

        if (DATE.equals(prestoType)) {
            long localMillis = ((Date) jdbcObject).getTime();
            // Convert it to a ~midnight in UTC.
            long utcMillis = ISOChronology.getInstance().getZone().getMillisKeepLocal(UTC, localMillis);
            // convert to days
            return MILLISECONDS.toDays(utcMillis);
        }

        if (prestoType instanceof VarcharType) {
            return utf8Slice((String) jdbcObject);
        }

        if (prestoType instanceof CharType) {
            return utf8Slice(CharMatcher.is(' ').trimTrailingFrom((String) jdbcObject));
        }

        throw new PrestoException(NOT_SUPPORTED, format("Unsupported type %s and object type %s", prestoType, jdbcObject.getClass()));
    }