private static ArrowType getArrowType()

in odps-sdk/odps-sdk-table-api/src/main/java/com/aliyun/odps/table/utils/SchemaUtils.java [123:189]


    private static ArrowType getArrowType(TypeInfo typeInfo,
                                          ArrowOptions options) {
        ArrowType arrowType = null;
        switch (typeInfo.getOdpsType()) {
            case CHAR:
            case VARCHAR:
            case JSON:
            case STRING:
                arrowType = new ArrowType.Utf8();
                break;
            case BINARY:
                arrowType = new ArrowType.Binary();
                break;
            case TINYINT:
                arrowType = new ArrowType.Int(8, true);
                break;
            case SMALLINT:
                arrowType = new ArrowType.Int(16, true);
                break;
            case INT:
                arrowType = new ArrowType.Int(32, true);
                break;
            case BIGINT:
                arrowType = new ArrowType.Int(64, true);
                break;
            case BOOLEAN:
                arrowType = new ArrowType.Bool();
                break;
            case FLOAT:
                arrowType = new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE);
                break;
            case DOUBLE:
                arrowType = new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE);
                break;
            case DECIMAL:
                // set decimal(54,18) to decimal(38,18)
                if (((DecimalTypeInfo) typeInfo).getPrecision() == DECIMAL_DEFAULT_PRECISION &&
                        ((DecimalTypeInfo) typeInfo).getScale() == DECIMAL_DEFAULT_SCALE) {
                    arrowType = new ArrowType.Decimal(ARROW_DECIMAL_DEFAULT_PRECISION, ARROW_DECIMAL_DEFAULT_SCALE);
                } else {
                    arrowType = new ArrowType.Decimal(((DecimalTypeInfo) typeInfo).getPrecision(), ((DecimalTypeInfo) typeInfo).getScale());
                }
                break;
            case DATE:
                arrowType = new ArrowType.Date(DateUnit.DAY);
                break;
            case DATETIME:
                arrowType = parseTimeStamp(options.getDateTimeUnit());
                break;
            case TIMESTAMP:
            case TIMESTAMP_NTZ:
                arrowType = parseTimeStamp(options.getTimestampUnit());
                break;
            case ARRAY:
                arrowType = new ArrowType.List();
                break;
            case STRUCT:
                arrowType = new ArrowType.Struct();
                break;
            case MAP:
                arrowType = new ArrowType.Map(false);
                break;
            default:
                throw new UnsupportedOperationException("Unsupported type: " + typeInfo.getOdpsType());
        }
        return arrowType;
    }