lightzhao commented on code in PR #3990:
URL:
https://github.com/apache/incubator-seatunnel/pull/3990#discussion_r1085092201
##########
seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/source/PulsarSource.java:
##########
@@ -226,10 +234,37 @@ private void setPartitionDiscoverer(Config config) {
}
private void setDeserialization(Config config) {
- String format = config.getString("format");
- // TODO: format SPI
- SeaTunnelRowType rowType =
SeaTunnelSchema.buildWithConfig(config.getConfig(SeaTunnelSchema.SCHEMA.key())).getSeaTunnelRowType();
- deserialization = (DeserializationSchema<T>) new
JsonDeserializationSchema(false, false, rowType);
+ String schemaKey = SeaTunnelSchema.SCHEMA.key();
+ if (config.hasPath(schemaKey)) {
+ Config schema = config.getConfig(schemaKey);
+ SeaTunnelRowType rowType =
SeaTunnelSchema.buildWithConfig(schema).getSeaTunnelRowType();
+ String format = DEFAULT_FORMAT;
+ if (config.hasPath(FORMAT.key())) {
+ format = config.getString(FORMAT.key());
+ }
+ if (DEFAULT_FORMAT.equals(format)) {
+ deserialization = (DeserializationSchema<T>) new
JsonDeserializationSchema(false, false, rowType);
+ } else if (TEXT_FORMAT.equals(format)) {
+ String delimiter = DEFAULT_FIELD_DELIMITER;
+ if (config.hasPath(FIELD_DELIMITER.key())) {
+ delimiter = config.getString(FIELD_DELIMITER.key());
+ }
+ deserialization = (DeserializationSchema<T>)
TextDeserializationSchema.builder()
+ .seaTunnelRowType(rowType)
+ .delimiter(delimiter)
+ .build();
+ } else {
+ // TODO: use format SPI
+ throw new
SeaTunnelJsonFormatException(CommonErrorCode.UNSUPPORTED_DATA_TYPE,
Review Comment:
done.
--
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]