You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/08/03 09:26:22 UTC
[GitHub] [incubator-seatunnel] hanwei996 opened a new pull request, #2356: Modify conversion error, new increase format match
hanwei996 opened a new pull request, #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
## Purpose of this pull request
https://github.com/apache/incubator-seatunnel/issues/2355
https://github.com/apache/incubator-seatunnel/issues/2313#issuecomment-1200536758 : The problem has not been addressed at its root
kafka source ClassCastException: com.fasterxml.jackson.databind.node.ObjectNode cannot be cast to com.fasterxml.jackson.databind.node.ArrayNode
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
## Check list
* [x] Code changed are covered with tests, or it does not need tests for reason:
* [x] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938370011
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-kafka/src/main/java/org/apache/seatunnel/flink/kafka/source/KafkaTableStream.java:
##########
@@ -110,8 +110,19 @@ public void prepare(FlinkEnvironment env) {
}
}
String schemaContent = config.getString(SCHEMA);
- format = FormatType.from(config.getString(SOURCE_FORMAT).trim().toLowerCase());
- schemaInfo = JsonUtils.parseArray(schemaContent);
+ String sourceFormat = config.getString(SOURCE_FORMAT).trim().toLowerCase();
+ format = FormatType.from(sourceFormat);
+ switch (sourceFormat){
+ case "csv":
+ schemaInfo = JsonUtils.parseArray(schemaContent);
+ break;
+ case "json":
+ case "avro":
+ schemaInfo = JsonUtils.parseObject(schemaContent);
Review Comment:
@Hisoka-X The new PR has been submitted
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#issuecomment-1223455542
Hi, Any update or need help?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938418520
##########
seatunnel-apis/seatunnel-api-flink/src/main/java/org/apache/seatunnel/flink/util/SchemaUtil.java:
##########
@@ -117,8 +120,27 @@ public static FormatDescriptor setFormat(FormatType format, Config config) throw
return formatDescriptor;
}
- private static void getJsonSchema(Schema schema, ObjectNode json) {
- Iterator<Map.Entry<String, JsonNode>> nodeIterator = json.fields();
+ private static void getJsonSchema(Schema schema, String json) {
Review Comment:
Sorry, but I don't think this method can implement schema parsing in list form. Although the fields in the list are processed cyclically, the returned schema does not reflect the attributes of the list. Maybe a field can be added for this situation: `list`, which points to the list at the outermost level of the schema
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938381810
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-kafka/src/main/java/org/apache/seatunnel/flink/kafka/source/KafkaTableStream.java:
##########
@@ -110,8 +110,19 @@ public void prepare(FlinkEnvironment env) {
}
}
String schemaContent = config.getString(SCHEMA);
- format = FormatType.from(config.getString(SOURCE_FORMAT).trim().toLowerCase());
- schemaInfo = JsonUtils.parseArray(schemaContent);
+ String sourceFormat = config.getString(SOURCE_FORMAT).trim().toLowerCase();
+ format = FormatType.from(sourceFormat);
+ switch (sourceFormat){
+ case "csv":
+ schemaInfo = JsonUtils.parseArray(schemaContent);
+ break;
+ case "json":
+ case "avro":
+ schemaInfo = JsonUtils.parseObject(schemaContent);
Review Comment:
> @Hisoka-X The new PR has been submitted
Seem like you should fix checkstyle
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r936708498
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-kafka/src/main/java/org/apache/seatunnel/flink/kafka/source/KafkaTableStream.java:
##########
@@ -110,8 +110,19 @@ public void prepare(FlinkEnvironment env) {
}
}
String schemaContent = config.getString(SCHEMA);
- format = FormatType.from(config.getString(SOURCE_FORMAT).trim().toLowerCase());
- schemaInfo = JsonUtils.parseArray(schemaContent);
+ String sourceFormat = config.getString(SOURCE_FORMAT).trim().toLowerCase();
+ format = FormatType.from(sourceFormat);
+ switch (sourceFormat){
+ case "csv":
+ schemaInfo = JsonUtils.parseArray(schemaContent);
+ break;
+ case "json":
+ case "avro":
+ schemaInfo = JsonUtils.parseObject(schemaContent);
Review Comment:
The method only support schema are object when use `json`. Can you support array in `json` schema both?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r936775854
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-kafka/src/main/java/org/apache/seatunnel/flink/kafka/source/KafkaTableStream.java:
##########
@@ -110,8 +110,19 @@ public void prepare(FlinkEnvironment env) {
}
}
String schemaContent = config.getString(SCHEMA);
- format = FormatType.from(config.getString(SOURCE_FORMAT).trim().toLowerCase());
- schemaInfo = JsonUtils.parseArray(schemaContent);
+ String sourceFormat = config.getString(SOURCE_FORMAT).trim().toLowerCase();
+ format = FormatType.from(sourceFormat);
+ switch (sourceFormat){
+ case "csv":
+ schemaInfo = JsonUtils.parseArray(schemaContent);
+ break;
+ case "json":
+ case "avro":
+ schemaInfo = JsonUtils.parseObject(schemaContent);
Review Comment:
Yes, I can.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938412318
##########
seatunnel-connectors/seatunnel-connectors-flink/seatunnel-connector-flink-kafka/src/main/java/org/apache/seatunnel/flink/kafka/source/KafkaTableStream.java:
##########
@@ -110,8 +110,19 @@ public void prepare(FlinkEnvironment env) {
}
}
String schemaContent = config.getString(SCHEMA);
- format = FormatType.from(config.getString(SOURCE_FORMAT).trim().toLowerCase());
- schemaInfo = JsonUtils.parseArray(schemaContent);
+ String sourceFormat = config.getString(SOURCE_FORMAT).trim().toLowerCase();
+ format = FormatType.from(sourceFormat);
+ switch (sourceFormat){
+ case "csv":
+ schemaInfo = JsonUtils.parseArray(schemaContent);
+ break;
+ case "json":
+ case "avro":
+ schemaInfo = JsonUtils.parseObject(schemaContent);
Review Comment:
@Hisoka-X Try again
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938847776
##########
seatunnel-apis/seatunnel-api-flink/src/main/java/org/apache/seatunnel/flink/util/SchemaUtil.java:
##########
@@ -117,8 +120,27 @@ public static FormatDescriptor setFormat(FormatType format, Config config) throw
return formatDescriptor;
}
- private static void getJsonSchema(Schema schema, ObjectNode json) {
- Iterator<Map.Entry<String, JsonNode>> nodeIterator = json.fields();
+ private static void getJsonSchema(Schema schema, String json) {
Review Comment:
Yes, there is a problem. Let me fix it
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] Hisoka-X commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
Hisoka-X commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r939850117
##########
seatunnel-apis/seatunnel-api-flink/src/main/java/org/apache/seatunnel/flink/util/SchemaUtil.java:
##########
@@ -117,8 +120,27 @@ public static FormatDescriptor setFormat(FormatType format, Config config) throw
return formatDescriptor;
}
- private static void getJsonSchema(Schema schema, ObjectNode json) {
- Iterator<Map.Entry<String, JsonNode>> nodeIterator = json.fields();
+ private static void getJsonSchema(Schema schema, String json) {
Review Comment:
Sorry for late reply, you are right, same as flink.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938979595
##########
seatunnel-apis/seatunnel-api-flink/src/main/java/org/apache/seatunnel/flink/util/SchemaUtil.java:
##########
@@ -117,8 +120,27 @@ public static FormatDescriptor setFormat(FormatType format, Config config) throw
return formatDescriptor;
}
- private static void getJsonSchema(Schema schema, ObjectNode json) {
- Iterator<Map.Entry<String, JsonNode>> nodeIterator = json.fields();
+ private static void getJsonSchema(Schema schema, String json) {
Review Comment:
The Flink schema is not familiar enough to know if this is the right thing to do

--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] hanwei996 commented on a diff in pull request #2356: Modify conversion error, new increase format match
Posted by GitBox <gi...@apache.org>.
hanwei996 commented on code in PR #2356:
URL: https://github.com/apache/incubator-seatunnel/pull/2356#discussion_r938982251
##########
seatunnel-apis/seatunnel-api-flink/src/main/java/org/apache/seatunnel/flink/util/SchemaUtil.java:
##########
@@ -117,8 +120,27 @@ public static FormatDescriptor setFormat(FormatType format, Config config) throw
return formatDescriptor;
}
- private static void getJsonSchema(Schema schema, ObjectNode json) {
- Iterator<Map.Entry<String, JsonNode>> nodeIterator = json.fields();
+ private static void getJsonSchema(Schema schema, String json) {
Review Comment:
@Hisoka-X
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org