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;
}
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;
}
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;
}
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;
}
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]));
}
Aggregations