public Object getFieldValue()

in flink-connector-kudu/src/main/java/org/apache/flink/connector/kudu/connector/writer/RowDataUpsertOperationMapper.java [64:138]


    public Object getFieldValue(RowData input, int i) {
        if (input == null || input.isNullAt(i)) {
            return null;
        }
        LogicalType fieldType = logicalTypes[i];
        switch (fieldType.getTypeRoot()) {
            case CHAR:
            case VARCHAR:
                {
                    StringData data = input.getString(i);
                    if (data != null) {
                        return data.toString();
                    }
                    return null;
                }
            case BOOLEAN:
                return input.getBoolean(i);
            case BINARY:
            case VARBINARY:
                return input.getBinary(i);
            case DECIMAL:
                {
                    DecimalType decimalType = (DecimalType) fieldType;
                    final int precision = decimalType.getPrecision();
                    final int scale = decimalType.getScale();
                    DecimalData data = input.getDecimal(i, precision, scale);
                    if (data != null) {
                        return data.toBigDecimal();
                    } else {
                        return null;
                    }
                }
            case TINYINT:
                return input.getByte(i);
            case SMALLINT:
                return input.getShort(i);
            case INTEGER:
            case DATE:
            case INTERVAL_YEAR_MONTH:
                return input.getInt(i);
            case TIME_WITHOUT_TIME_ZONE:
                final int timePrecision = getPrecision(fieldType);
                if (timePrecision < MIN_TIME_PRECISION || timePrecision > MAX_TIME_PRECISION) {
                    throw new UnsupportedOperationException(
                            String.format(
                                    "The precision %s of TIME type is out of the range [%s, %s] supported by "
                                            + "kudu connector",
                                    timePrecision, MIN_TIME_PRECISION, MAX_TIME_PRECISION));
                }
                return input.getInt(i);
            case BIGINT:
            case INTERVAL_DAY_TIME:
                return input.getLong(i);
            case FLOAT:
                return input.getFloat(i);
            case DOUBLE:
                return input.getDouble(i);
            case TIMESTAMP_WITHOUT_TIME_ZONE:
            case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
                final int timestampPrecision = getPrecision(fieldType);
                if (timestampPrecision < MIN_TIMESTAMP_PRECISION
                        || timestampPrecision > MAX_TIMESTAMP_PRECISION) {
                    throw new UnsupportedOperationException(
                            String.format(
                                    "The precision %s of TIMESTAMP type is out of the range [%s, %s] supported "
                                            + "by kudu connector",
                                    timestampPrecision,
                                    MIN_TIMESTAMP_PRECISION,
                                    MAX_TIMESTAMP_PRECISION));
                }
                return input.getTimestamp(i, timestampPrecision).toTimestamp();
            default:
                throw new UnsupportedOperationException("Unsupported type: " + fieldType);
        }
    }