Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Connector-V2][ES]Fix es field type not support binary(#4240) #4274

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.seatunnel.api.table.type.BasicType;
import org.apache.seatunnel.api.table.type.LocalTimeType;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.connectors.seatunnel.elasticsearch.exception.ElasticsearchConnectorErrorCode;
import org.apache.seatunnel.connectors.seatunnel.elasticsearch.exception.ElasticsearchConnectorException;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -32,6 +34,7 @@ public class EsTypeMappingSeaTunnelType {
put("string", BasicType.STRING_TYPE);
put("keyword", BasicType.STRING_TYPE);
put("text", BasicType.STRING_TYPE);
put("binary", BasicType.STRING_TYPE);
Hisoka-X marked this conversation as resolved.
Show resolved Hide resolved
put("boolean", BasicType.BOOLEAN_TYPE);
put("byte", BasicType.BYTE_TYPE);
put("short", BasicType.SHORT_TYPE);
Expand All @@ -44,7 +47,19 @@ public class EsTypeMappingSeaTunnelType {
}
};

/**
* if not find the mapping SeaTunnelDataType will throw runtime exception
*
* @param esType
* @return
*/
public static SeaTunnelDataType getSeaTunnelDataType(String esType) {
return MAPPING.get(esType);
SeaTunnelDataType seaTunnelDataType = MAPPING.get(esType);
if (seaTunnelDataType == null) {
throw new ElasticsearchConnectorException(
ElasticsearchConnectorErrorCode.ES_FIELD_TYPE_NOT_SUPPORT,
String.format("elasticsearch type is %s", esType));
}
return seaTunnelDataType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum ElasticsearchConnectorErrorCode implements SeaTunnelErrorCode {
LIST_INDEX_FAILED("ELASTICSEARCH-05", "List elasticsearch index failed"),
DROP_INDEX_FAILED("ELASTICSEARCH-06", "Drop elasticsearch index failed"),
CREATE_INDEX_FAILED("ELASTICSEARCH-07", "Create elasticsearch index failed"),
ES_FIELD_TYPE_NOT_SUPPORT("ELASTICSEARCH-08", "Not support the elasticsearch field type");
;

private final String code;
Expand Down