public DataType visit()

in src/main/java/org/apache/paimon/trino/TrinoTypeUtils.java [224:290]


        public DataType visit(Type trinoType) {
            if (trinoType instanceof io.trino.spi.type.CharType) {
                return DataTypes.CHAR(
                        Math.min(
                                io.trino.spi.type.CharType.MAX_LENGTH,
                                ((io.trino.spi.type.CharType) trinoType).getLength()));
            } else if (trinoType instanceof VarcharType) {
                Optional<Integer> length = ((VarcharType) trinoType).getLength();
                if (length.isPresent()) {
                    return DataTypes.VARCHAR(
                            Math.min(
                                    VarcharType.MAX_LENGTH,
                                    ((VarcharType) trinoType).getBoundedLength()));
                }
                return DataTypes.VARCHAR(VarcharType.MAX_LENGTH);
            } else if (trinoType instanceof io.trino.spi.type.BooleanType) {
                return DataTypes.BOOLEAN();
            } else if (trinoType instanceof VarbinaryType) {
                return DataTypes.VARBINARY(Integer.MAX_VALUE);
            } else if (trinoType instanceof io.trino.spi.type.DecimalType) {
                return DataTypes.DECIMAL(
                        ((io.trino.spi.type.DecimalType) trinoType).getPrecision(),
                        ((io.trino.spi.type.DecimalType) trinoType).getScale());
            } else if (trinoType instanceof TinyintType) {
                return DataTypes.TINYINT();
            } else if (trinoType instanceof SmallintType) {
                return DataTypes.SMALLINT();
            } else if (trinoType instanceof IntegerType) {
                return DataTypes.INT();
            } else if (trinoType instanceof BigintType) {
                return DataTypes.BIGINT();
            } else if (trinoType instanceof RealType) {
                return DataTypes.FLOAT();
            } else if (trinoType instanceof io.trino.spi.type.DoubleType) {
                return DataTypes.DOUBLE();
            } else if (trinoType instanceof io.trino.spi.type.DateType) {
                return DataTypes.DATE();
            } else if (trinoType instanceof io.trino.spi.type.TimeType) {
                return new TimeType();
            } else if (trinoType instanceof io.trino.spi.type.TimestampType) {
                int precision = ((io.trino.spi.type.TimestampType) trinoType).getPrecision();
                return new TimestampType(precision);
            } else if (trinoType instanceof TimestampWithTimeZoneType) {
                return DataTypes.TIMESTAMP_WITH_LOCAL_TIME_ZONE();
            } else if (trinoType instanceof io.trino.spi.type.ArrayType) {
                return DataTypes.ARRAY(
                        visit(((io.trino.spi.type.ArrayType) trinoType).getElementType()));
            } else if (trinoType instanceof io.trino.spi.type.MapType) {
                return DataTypes.MAP(
                        visit(((io.trino.spi.type.MapType) trinoType).getKeyType()),
                        visit(((io.trino.spi.type.MapType) trinoType).getValueType()));
            } else if (trinoType instanceof io.trino.spi.type.RowType) {
                io.trino.spi.type.RowType rowType = (io.trino.spi.type.RowType) trinoType;
                List<DataField> dataFields =
                        rowType.getFields().stream()
                                .map(
                                        field ->
                                                new DataField(
                                                        currentIndex.getAndIncrement(),
                                                        field.getName().get(),
                                                        visit(field.getType())))
                                .collect(Collectors.toList());
                return new RowType(true, dataFields);
            } else {
                throw new UnsupportedOperationException("Unsupported type: " + trinoType);
            }
        }