Search in sources :

Example 1 with SinkFieldResponse

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse in project incubator-inlong by apache.

the class HiveStreamSinkOperation method getById.

@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    String existType = entity.getSinkType();
    Preconditions.checkTrue(Constant.SINK_HIVE.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_HIVE, existType));
    SinkResponse response = this.getFromEntity(entity, HiveSinkResponse::new);
    List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
    List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
    response.setFieldList(infos);
    return response;
}
Also used : SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) HiveSinkResponse(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse) HiveSinkResponse(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 2 with SinkFieldResponse

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse in project incubator-inlong by apache.

the class IcebergStreamSinkOperation method getById.

@Override
public SinkResponse getById(String sinkType, Integer id) {
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    String existType = entity.getSinkType();
    Preconditions.checkTrue(Constant.SINK_ICEBERG.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_ICEBERG, existType));
    SinkResponse response = this.getFromEntity(entity, IcebergSinkResponse::new);
    List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
    List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
    response.setFieldList(infos);
    return response;
}
Also used : IcebergSinkResponse(org.apache.inlong.manager.common.pojo.sink.iceberg.IcebergSinkResponse) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity) IcebergSinkResponse(org.apache.inlong.manager.common.pojo.sink.iceberg.IcebergSinkResponse)

Example 3 with SinkFieldResponse

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse in project incubator-inlong by apache.

the class KafkaStreamSinkOperation method getById.

@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    String existType = entity.getSinkType();
    Preconditions.checkTrue(Constant.SINK_KAFKA.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_KAFKA, existType));
    SinkResponse response = this.getFromEntity(entity, KafkaSinkResponse::new);
    List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
    List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
    response.setFieldList(infos);
    return response;
}
Also used : KafkaSinkResponse(org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkResponse) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) KafkaSinkResponse(org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkResponse) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 4 with SinkFieldResponse

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse in project incubator-inlong by apache.

the class ClickHouseStreamSinkOperation method getById.

@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    String existType = entity.getSinkType();
    Preconditions.checkTrue(Constant.SINK_CLICKHOUSE.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_CLICKHOUSE, existType));
    SinkResponse response = this.getFromEntity(entity, ClickHouseSinkResponse::new);
    List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
    List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
    response.setFieldList(infos);
    return response;
}
Also used : ClickHouseSinkResponse(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) ClickHouseSinkResponse(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 5 with SinkFieldResponse

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse in project incubator-inlong by apache.

the class FieldInfoUtils method createFieldInfo.

/**
 * Get field info list.
 * TODO 1. Support partition field, 2. Add is_metadata field in StreamSinkFieldEntity
 */
public static FieldMappingRule createFieldInfo(boolean isAllMigration, List<SinkFieldResponse> fieldList, List<FieldInfo> sourceFields, List<FieldInfo> sinkFields, String partitionField) {
    List<FieldMappingUnit> fieldMappingUnitList = new ArrayList<>();
    if (isAllMigration) {
        setAllMigrationBuiltInField(sourceFields, sinkFields, fieldMappingUnitList);
    } else {
        boolean duplicate = false;
        for (SinkFieldResponse field : fieldList) {
            // If the field name equals to build-in field, new a build-in field info
            FieldInfo sourceFieldInfo = getFieldInfo(field.getSourceFieldName(), field.getSourceFieldType(), field.getIsSourceMetaField() == 1);
            sourceFields.add(sourceFieldInfo);
            // Get sink field info
            String sinkFieldName = field.getFieldName();
            if (sinkFieldName.equals(partitionField)) {
                duplicate = true;
            }
            FieldInfo sinkFieldInfo = getSinkFieldInfo(field.getFieldName(), field.getFieldType(), field.getSourceFieldName(), field.getIsSourceMetaField() == 1);
            sinkFields.add(sinkFieldInfo);
            fieldMappingUnitList.add(new FieldMappingUnit(sourceFieldInfo, sinkFieldInfo));
        }
        // If no partition field in the ordinary fields, add the partition field to the first position
        if (!duplicate && StringUtils.isNotEmpty(partitionField)) {
            FieldInfo fieldInfo = new FieldInfo(partitionField, new TimestampFormatInfo("MILLIS"));
            sourceFields.add(0, fieldInfo);
        }
    }
    return new FieldMappingRule(fieldMappingUnitList.toArray(new FieldMappingUnit[0]));
}
Also used : FieldMappingRule(org.apache.inlong.sort.protocol.transformation.FieldMappingRule) TimestampFormatInfo(org.apache.inlong.sort.formats.common.TimestampFormatInfo) ArrayList(java.util.ArrayList) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) FieldMappingUnit(org.apache.inlong.sort.protocol.transformation.FieldMappingRule.FieldMappingUnit) BuiltInFieldInfo(org.apache.inlong.sort.protocol.BuiltInFieldInfo) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo)

Aggregations

SinkFieldResponse (org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse)5 SinkResponse (org.apache.inlong.manager.common.pojo.sink.SinkResponse)4 StreamSinkEntity (org.apache.inlong.manager.dao.entity.StreamSinkEntity)4 StreamSinkFieldEntity (org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)4 ArrayList (java.util.ArrayList)1 ClickHouseSinkResponse (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse)1 HiveSinkResponse (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse)1 IcebergSinkResponse (org.apache.inlong.manager.common.pojo.sink.iceberg.IcebergSinkResponse)1 KafkaSinkResponse (org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkResponse)1 TimestampFormatInfo (org.apache.inlong.sort.formats.common.TimestampFormatInfo)1 BuiltInFieldInfo (org.apache.inlong.sort.protocol.BuiltInFieldInfo)1 FieldInfo (org.apache.inlong.sort.protocol.FieldInfo)1 FieldMappingRule (org.apache.inlong.sort.protocol.transformation.FieldMappingRule)1 FieldMappingUnit (org.apache.inlong.sort.protocol.transformation.FieldMappingRule.FieldMappingUnit)1