public static String toDorisType()

in flink-doris-connector/src/main/java/org/apache/doris/flink/tools/cdc/postgres/PostgresType.java [70:159]


    public static String toDorisType(String postgresType, Integer precision, Integer scale) {
        postgresType = postgresType.toLowerCase();
        if (postgresType.startsWith("_")) {
            return DorisType.STRING;
        }
        switch (postgresType) {
            case INT2:
            case SMALLSERIAL:
                return DorisType.SMALLINT;
            case INT4:
            case SERIAL:
                return DorisType.INT;
            case INT8:
            case BIGSERIAL:
                return DorisType.BIGINT;
            case NUMERIC:
                return precision != null && precision > 0 && precision <= 38
                        ? String.format(
                                "%s(%s,%s)",
                                DorisType.DECIMAL_V3,
                                precision,
                                scale != null && scale >= 0 ? scale : 0)
                        : DorisType.STRING;
            case FLOAT4:
                return DorisType.FLOAT;
            case FLOAT8:
                return DorisType.DOUBLE;
            case TIMESTAMP:
            case TIMESTAMPTZ:
                return String.format(
                        "%s(%s)", DorisType.DATETIME_V2, Math.min(scale == null ? 0 : scale, 6));
            case DATE:
                return DorisType.DATE_V2;
            case BOOL:
                return DorisType.BOOLEAN;
            case BIT:
                return precision == 1 ? DorisType.BOOLEAN : DorisType.STRING;
            case BPCHAR:
            case VARCHAR:
                Preconditions.checkNotNull(precision);
                return precision * 3 > 65533
                        ? DorisType.STRING
                        : String.format("%s(%s)", DorisType.VARCHAR, precision * 3);
            case POINT:
            case LINE:
            case LSEG:
            case BOX:
            case PATH:
            case POLYGON:
            case CIRCLE:
            case TEXT:
            case TIME:
            case TIMETZ:
            case INTERVAL:
            case CIDR:
            case INET:
            case MACADDR:
            case VARBIT:
            case UUID:
            case BYTEA:
                return DorisType.STRING;
            case JSON:
            case JSONB:
                return DorisType.JSONB;
                /* Compatible with doris1.2 array type can only be used in dup table,
                   and then converted to array in the next version
                case _BOOL:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.BOOLEAN);
                case _INT2:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.TINYINT);
                case _INT4:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.INT);
                case _INT8:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.BIGINT);
                case _FLOAT4:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.FLOAT);
                case _FLOAT8:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.DOUBLE);
                case _TEXT:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.STRING);
                case _DATE:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.DATE_V2);
                case _TIMESTAMP:
                    return String.format("%s<%s>", DorisType.ARRAY, DorisType.DATETIME_V2);
                **/
            default:
                throw new UnsupportedOperationException(
                        "Unsupported Postgres Type: " + postgresType);
        }
    }