CosmosNi commented on code in PR #6425:
URL: https://github.com/apache/seatunnel/pull/6425#discussion_r1582027746
##########
seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/source/ElasticsearchSource.java:
##########
@@ -55,27 +64,43 @@ public class ElasticsearchSource
private List<String> source;
+ private Map<String, String> arrayColumn;
+
public ElasticsearchSource(ReadonlyConfig config) {
this.config = config;
if (config.getOptional(TableSchemaOptions.SCHEMA).isPresent()) {
// todo: We need to remove the schema in ES.
+ log.warn(
+ "The schema config in ElasticSearch sink is deprecated,
please use source config instead!");
catalogTable = CatalogTableUtil.buildWithConfig(config);
source =
Arrays.asList(catalogTable.getSeaTunnelRowType().getFieldNames());
} else {
source = config.get(SourceConfig.SOURCE);
+ arrayColumn = config.get(SourceConfig.ARRAY_COLUMN);
EsRestClient esRestClient = EsRestClient.createInstance(config);
Map<String, BasicTypeDefine<EsType>> esFieldType =
esRestClient.getFieldTypeMapping(config.get(SourceConfig.INDEX), source);
esRestClient.close();
- SeaTunnelDataType<?>[] fieldTypes = new
SeaTunnelDataType[source.size()];
- for (int i = 0; i < source.size(); i++) {
- BasicTypeDefine<EsType> esType =
esFieldType.get(source.get(i));
- SeaTunnelDataType<?> seaTunnelDataType =
-
ElasticSearchTypeConverter.INSTANCE.convert(esType).getDataType();
- fieldTypes[i] = seaTunnelDataType;
+
+ if (CollectionUtils.isEmpty(source)) {
+ source = new ArrayList<>(esFieldType.keySet());
}
+ SeaTunnelDataType[] fieldTypes = getSeaTunnelDataType(esFieldType,
source);
TableSchema.Builder builder = TableSchema.builder();
+
+ for (Map.Entry<String, String> entry : arrayColumn.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ SeaTunnelDataType<?> dataType =
+
SeaTunnelDataTypeConvertorUtil.deserializeSeaTunnelDataType(key, value);
+ builder.column(PhysicalColumn.of(key, dataType, 0, true, null,
null));
+ }
for (int i = 0; i < source.size(); i++) {
+ String key = source.get(i);
+ if (arrayColumn.containsKey(key)) {
+ continue;
+ }
+
builder.column(
PhysicalColumn.of(source.get(i), fieldTypes[i], 0,
true, null, null));
}
Review Comment:
sorry. I don't understand.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]