presto-connector/src/main/java/com/facebook/presto/maxcompute/utils/TypeConvertUtils.java [40:107]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TypeConvertUtils
{
    private TypeConvertUtils() {}

    /**
     * Convert MaxCompute data type to Presto data type.
     * <p>
     * This method is responsible for mapping the {@link TypeInfo} type of MaxCompute to the {@link Type} type of Presto.
     * Note: This method currently does not support complex types (such as arrays, maps, and structures).
     *
     * @param odpsType MaxCompute data type information
     * @return corresponding Presto data type
     * @throws PrestoException if an unsupported data type is encountered
     * <p>
     * The supported MaxCompute to Presto type mapping is as follows:
     * <ul>
     * <li>TINYINT -> {@link TinyintType#TINYINT}</li>
     * <li>SMALLINT -> {@link SmallintType#SMALLINT}</li>
     * <li>INT -> {@link IntegerType#INTEGER}</li>
     * <li>BIGINT -> {@link BigintType#BIGINT}</li>
     * <li>CHAR -> {@link CharType} created based on character length</li>
     * <li>VARCHAR -> {@link VarcharType} created based on character length</li>
     * <li>STRING, JSON -> {@link VarcharType#VARCHAR}</li>
     * <li>BINARY -> {@link VarbinaryType#VARBINARY}</li>
     * <li>DATE -> {@link DateType#DATE}</li>
     * <li>TIMESTAMP, TIMESTAMP_NTZ, DATETIME -> {@link TimestampType#TIMESTAMP}</li>
     * <li>FLOAT -> {@link RealType#REAL}</li>
     * <li>DOUBLE -> {@link DoubleType#DOUBLE}</li>
     * <li>DECIMAL -> {@link DecimalType} created based on precision and scale</li>
     * <li>BOOLEAN -> {@link BooleanType#BOOLEAN}</li>
     * </ul>
     * If MaxCompute encounters an unsupported type, it will throw {@link PrestoException}.
     */
    public static Type toPrestoType(TypeInfo odpsType)
    {
        // TODO: support complex type (array, map, struct)
        switch (odpsType.getOdpsType()) {
            case TINYINT:
                // long
                return TinyintType.TINYINT;
            case SMALLINT:
                // long
                return SmallintType.SMALLINT;
            case INT:
                // long
                return IntegerType.INTEGER;
            case BIGINT:
                // long
                return BigintType.BIGINT;
            case CHAR:
                // Slice
                return CharType.createCharType(((CharTypeInfo) odpsType).getLength());
            case VARCHAR:
                // Slice
                return VarcharType.createVarcharType(((VarcharTypeInfo) odpsType).getLength());
            case STRING:
            case JSON:
                // Slice
                return VarcharType.VARCHAR;
            case BINARY:
                // Slice
                return VarbinaryType.VARBINARY;
            case DATE:
                // long
                return DateType.DATE;
            case TIMESTAMP:
            case TIMESTAMP_NTZ:
            case DATETIME:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



trino-connector/src/main/java/io/trino/plugin/maxcompute/utils/TypeConvertUtils.java [40:107]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class TypeConvertUtils
{
    private TypeConvertUtils() {}

    /**
     * Convert MaxCompute data type to Presto data type.
     * <p>
     * This method is responsible for mapping the {@link TypeInfo} type of MaxCompute to the {@link Type} type of Presto.
     * Note: This method currently does not support complex types (such as arrays, maps, and structures).
     *
     * @param odpsType MaxCompute data type information
     * @return corresponding Presto data type
     * @throws TrinoException if an unsupported data type is encountered
     * <p>
     * The supported MaxCompute to Presto type mapping is as follows:
     * <ul>
     * <li>TINYINT -> {@link TinyintType#TINYINT}</li>
     * <li>SMALLINT -> {@link SmallintType#SMALLINT}</li>
     * <li>INT -> {@link IntegerType#INTEGER}</li>
     * <li>BIGINT -> {@link BigintType#BIGINT}</li>
     * <li>CHAR -> {@link CharType} created based on character length</li>
     * <li>VARCHAR -> {@link VarcharType} created based on character length</li>
     * <li>STRING, JSON -> {@link VarcharType#VARCHAR}</li>
     * <li>BINARY -> {@link VarbinaryType#VARBINARY}</li>
     * <li>DATE -> {@link DateType#DATE}</li>
     * <li>TIMESTAMP, TIMESTAMP_NTZ, DATETIME -> {@link TimestampType#TIMESTAMP}</li>
     * <li>FLOAT -> {@link RealType#REAL}</li>
     * <li>DOUBLE -> {@link DoubleType#DOUBLE}</li>
     * <li>DECIMAL -> {@link DecimalType} created based on precision and scale</li>
     * <li>BOOLEAN -> {@link BooleanType#BOOLEAN}</li>
     * </ul>
     * If MaxCompute encounters an unsupported type, it will throw {@link TrinoException}.
     */
    public static Type toPrestoType(TypeInfo odpsType)
    {
        // TODO: support complex type (array, map, struct)
        switch (odpsType.getOdpsType()) {
            case TINYINT:
                // long
                return TinyintType.TINYINT;
            case SMALLINT:
                // long
                return SmallintType.SMALLINT;
            case INT:
                // long
                return IntegerType.INTEGER;
            case BIGINT:
                // long
                return BigintType.BIGINT;
            case CHAR:
                // Slice
                return CharType.createCharType(((CharTypeInfo) odpsType).getLength());
            case VARCHAR:
                // Slice
                return VarcharType.createVarcharType(((VarcharTypeInfo) odpsType).getLength());
            case STRING:
            case JSON:
                // Slice
                return VarcharType.VARCHAR;
            case BINARY:
                // Slice
                return VarbinaryType.VARBINARY;
            case DATE:
                // long
                return DateType.DATE;
            case TIMESTAMP:
            case TIMESTAMP_NTZ:
            case DATETIME:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



