You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "dyp12 (via GitHub)" <gi...@apache.org> on 2025/08/14 07:16:06 UTC

[PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

dyp12 opened a new pull request, #9701:
URL: https://github.com/apache/seatunnel/pull/9701

   <!--
   
   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/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
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   https://github.com/apache/seatunnel/issues/9675
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)


-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278162212


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-kafka-e2e/src/test/java/org/apache/seatunnel/e2e/connector/kafka/KafkaFormatIT.java:
##########
@@ -562,20 +562,20 @@ private void checkCanalFormat() {
     private void checkMaxWellFormat() {
         List<String> expectedResult =
                 Arrays.asList(
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":\"1.0\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":108,\"name\":\"jacket\",\"description\":\"water resistent black wind breaker\",\"weight\":\"0.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"4.56\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"7.88\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"DELETE\"}");
+                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",

Review Comment:
   We should put it back into row metadata fields. Please refer https://github.com/apache/seatunnel/commit/385814e7f11d55918dd5153c14ea80ff1dbc1f59#diff-6a75706e1227f94a09112c28662d4c2f91aa4d563e6ff032feee5ed9e3102f6fR141



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278143647


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -88,9 +98,12 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
+                new String[] {"data", "type", "tableId", "ts"},

Review Comment:
   The cancel format is database and table fields, not tableId. Please refer https://docs.pingcap.com/zh/tidb/stable/ticdc-canal-json/#dml-event



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java:
##########
@@ -109,6 +109,12 @@ public SeaTunnelRow copy(int[] indexMapping) {
         return newRow;
     }
 
+    public SeaTunnelRow copyWithOptions(int[] indexMapping) {
+        SeaTunnelRow newRow = copy(indexMapping);
+        newRow.setOptions(this.getOptions());
+        return newRow;
+    }

Review Comment:
   I think all copy method should with options. Please update those method https://github.com/apache/seatunnel/blob/9212a77140bb9a310237b4ef82126d42b5d767e6/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java#L92-L111



##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/ogg/OggJsonSerializationSchema.java:
##########
@@ -79,7 +88,7 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
-                new SeaTunnelDataType[] {databaseSchema, STRING_TYPE});
+                new String[] {"data", "type", "tableId", "op_ts"},

Review Comment:
   ogg json doesn't contains `tableId`. Please refer https://help.aliyun.com/zh/datahub/developer-reference/ogg-for-big-data-kafka



##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/debezium/DebeziumJsonSerializationSchema.java:
##########
@@ -78,7 +94,9 @@ public byte[] serialize(SeaTunnelRow row) {
 
     private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchema) {
         return new SeaTunnelRowType(
-                new String[] {"before", "after", "op"},
-                new SeaTunnelDataType[] {databaseSchema, databaseSchema, STRING_TYPE});
+                new String[] {"before", "after", "op", "tableId", "ts_ms"},

Review Comment:
   The debezium format doesn't contains `tableId`. Please refer https://help.aliyun.com/zh/flink/debezium



##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/maxwell/MaxWellJsonSerializationSchema.java:
##########
@@ -87,7 +96,7 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
-                new SeaTunnelDataType[] {databaseSchema, STRING_TYPE});
+                new String[] {"data", "type", "tableId", "ts"},

Review Comment:
   same as canal, maxwell doesn'ts contains tableId too. Please refer https://help.aliyun.com/zh/flink/maxwell-format



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278169907


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -88,9 +98,12 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
+                new String[] {"data", "type", "tableId", "ts"},

Review Comment:
   We should update SeaTunnelRowType to CatalogTable in https://github.com/apache/seatunnel/blob/9212a77140bb9a310237b4ef82126d42b5d767e6/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java#L49
   
   Then we can get table and database from CatalogTable.



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278374805


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -88,9 +98,12 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
+                new String[] {"data", "type", "tableId", "ts"},

Review Comment:
   > We should update SeaTunnelRowType to CatalogTable in
   > 
   > https://github.com/apache/seatunnel/blob/9212a77140bb9a310237b4ef82126d42b5d767e6/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java#L49
   > 
   > Then we can get table and database from CatalogTable.
   
   MetadataUtil.getDatabase  use tableId to get db,maybe can use it , update SeaTunnelRowType to CatalogTable will change manay file
   <img width="861" height="362" alt="image" src="https://github.com/user-attachments/assets/600cdb0c-feb1-430b-9239-4b8409e1270e" />
   



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284413817


##########
seatunnel-formats/seatunnel-format-json/src/test/java/org/apache/seatunnel/format/json/ogg/OggJsonSerDeSchemaTest.java:
##########
@@ -206,27 +206,26 @@ public void runTest(List<String> lines, OggJsonDeserializationSchema deserializa
 
         List<String> expectedResult =
                 Arrays.asList(
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":3.14},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":8.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":0.8},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":0.75},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":0.875},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":1.0},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.3},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":108,\"name\":\"jacket\",\"description\":\"water resistent black wind breaker\",\"weight\":0.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":22.2},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":1.0},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"18oz carpenter hammer\",\"weight\":1.0},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.3},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"water resistent white wind breaker\",\"weight\":0.2},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.18},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"water resistent white wind breaker\",\"weight\":0.2},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"new water resistent white wind breaker\",\"weight\":0.5},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.18},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.17},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.17},\"type\":\"DELETE\"}");
-
+                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":3.14},\"type\":\"INSERT\",\"table\":\"..test\",\"op_ts\":1589384406000}",

Review Comment:
   > why table is `..test`?
   
   '..test' is because of db and schema is null



-- 
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


Re: [PR] [Feature][Format] Improve maxwell_json,canal_json,debezium_json format add ts_ms and table [seatunnel]

Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w merged PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701


-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284401358


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -62,6 +67,15 @@ public byte[] serialize(SeaTunnelRow row) {
             String opType = rowKind2String(row.getRowKind());
             reuse.setField(0, new SeaTunnelRow[] {row});
             reuse.setField(1, opType);
+            if (!StringUtils.isEmpty(row.getTableId())) {
+                reuse.setField(2, TablePath.of(row.getTableId()).getDatabaseName());
+                reuse.setField(3, TablePath.of(row.getTableId()).getTableName());
+            }
+
+            if (row.getOptions() != null && row.getOptions().containsKey(EVENT_TIME.getName())) {
+                reuse.setField(4, row.getOptions().get(EVENT_TIME.getName()));

Review Comment:
   > Should we standardize the precision of eventtime? I see that the unit is sometimes seconds and sometimes milliseconds. Can we standardize it to milliseconds?
   
   now all use milliseconds,when read data ,all eventtime is milliseconds
   <img width="881" height="231" alt="image" src="https://github.com/user-attachments/assets/4797a63e-8e25-4a45-b9fd-3d6af7f89bee" />
   



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278128450


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-kafka-e2e/src/test/java/org/apache/seatunnel/e2e/connector/kafka/KafkaFormatIT.java:
##########
@@ -562,20 +562,20 @@ private void checkCanalFormat() {
     private void checkMaxWellFormat() {
         List<String> expectedResult =
                 Arrays.asList(
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":\"1.0\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":108,\"name\":\"jacket\",\"description\":\"water resistent black wind breaker\",\"weight\":\"0.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"4.56\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"7.88\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"DELETE\"}");
+                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",

Review Comment:
   why ts value is null?



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278147275


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-kafka-e2e/src/test/java/org/apache/seatunnel/e2e/connector/kafka/KafkaFormatIT.java:
##########
@@ -562,20 +562,20 @@ private void checkCanalFormat() {
     private void checkMaxWellFormat() {
         List<String> expectedResult =
                 Arrays.asList(
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":\"1.0\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":108,\"name\":\"jacket\",\"description\":\"water resistent black wind breaker\",\"weight\":\"0.1\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"4.56\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"5.3\"},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":\"7.88\"},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":\"22.2\"},\"type\":\"DELETE\"}");
+                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":\"3.14\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":\"8.1\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":\"0.8\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":\"0.75\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",
+                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":\"0.875\"},\"type\":\"INSERT\",\"tableId\":\"\",\"ts\":null}",

Review Comment:
   > why ts value is null?
   
   CanalJsonDeserializationSchema  read data remove ts field, so when sink , the ts field is null 
   <img width="1152" height="239" alt="image" src="https://github.com/user-attachments/assets/9932d699-86dd-4d6b-afa7-e6fad7aecd44" />
   



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284336471


##########
seatunnel-formats/seatunnel-format-json/src/test/java/org/apache/seatunnel/format/json/ogg/OggJsonSerDeSchemaTest.java:
##########
@@ -206,27 +206,26 @@ public void runTest(List<String> lines, OggJsonDeserializationSchema deserializa
 
         List<String> expectedResult =
                 Arrays.asList(
-                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":3.14},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":102,\"name\":\"car battery\",\"description\":\"12V car battery\",\"weight\":8.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":103,\"name\":\"12-pack drill bits\",\"description\":\"12-pack of drill bits with sizes ranging from #40 to #3\",\"weight\":0.8},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":104,\"name\":\"hammer\",\"description\":\"12oz carpenter's hammer\",\"weight\":0.75},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":105,\"name\":\"hammer\",\"description\":\"14oz carpenter's hammer\",\"weight\":0.875},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":1.0},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.3},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":108,\"name\":\"jacket\",\"description\":\"water resistent black wind breaker\",\"weight\":0.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":109,\"name\":\"spare tire\",\"description\":\"24 inch spare tire\",\"weight\":22.2},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"16oz carpenter's hammer\",\"weight\":1.0},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":106,\"name\":\"hammer\",\"description\":\"18oz carpenter hammer\",\"weight\":1.0},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.3},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":107,\"name\":\"rocks\",\"description\":\"box of assorted rocks\",\"weight\":5.1},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"water resistent white wind breaker\",\"weight\":0.2},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.18},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"water resistent white wind breaker\",\"weight\":0.2},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":110,\"name\":\"jacket\",\"description\":\"new water resistent white wind breaker\",\"weight\":0.5},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.18},\"type\":\"DELETE\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.17},\"type\":\"INSERT\"}",
-                        "{\"data\":{\"id\":111,\"name\":\"scooter\",\"description\":\"Big 2-wheel scooter \",\"weight\":5.17},\"type\":\"DELETE\"}");
-
+                        "{\"data\":{\"id\":101,\"name\":\"scooter\",\"description\":\"Small 2-wheel scooter\",\"weight\":3.14},\"type\":\"INSERT\",\"table\":\"..test\",\"op_ts\":1589384406000}",

Review Comment:
   why table is `..test`?



##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -62,6 +67,15 @@ public byte[] serialize(SeaTunnelRow row) {
             String opType = rowKind2String(row.getRowKind());
             reuse.setField(0, new SeaTunnelRow[] {row});
             reuse.setField(1, opType);
+            if (!StringUtils.isEmpty(row.getTableId())) {
+                reuse.setField(2, TablePath.of(row.getTableId()).getDatabaseName());
+                reuse.setField(3, TablePath.of(row.getTableId()).getTableName());
+            }
+
+            if (row.getOptions() != null && row.getOptions().containsKey(EVENT_TIME.getName())) {
+                reuse.setField(4, row.getOptions().get(EVENT_TIME.getName()));

Review Comment:
   Should we standardize the precision of eventtime? I see that the unit is sometimes seconds and sometimes milliseconds. Can we standardize it to milliseconds?



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284416004


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonDeserializationSchema.java:
##########
@@ -137,6 +140,7 @@ public void deserialize(ObjectNode jsonNode, Collector<SeaTunnelRow> out) throws
 
             JsonNode dataNode = jsonNode.get(FIELD_DATA);
             String op = jsonNode.get(FIELD_TYPE).asText();
+            JsonNode tsNode = jsonNode.get(FIELD_TS);

Review Comment:
   So this value is milliseconds?



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284413499


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -62,6 +67,15 @@ public byte[] serialize(SeaTunnelRow row) {
             String opType = rowKind2String(row.getRowKind());
             reuse.setField(0, new SeaTunnelRow[] {row});
             reuse.setField(1, opType);
+            if (!StringUtils.isEmpty(row.getTableId())) {
+                reuse.setField(2, TablePath.of(row.getTableId()).getDatabaseName());
+                reuse.setField(3, TablePath.of(row.getTableId()).getTableName());
+            }
+
+            if (row.getOptions() != null && row.getOptions().containsKey(EVENT_TIME.getName())) {
+                reuse.setField(4, row.getOptions().get(EVENT_TIME.getName()));

Review Comment:
   Could you add some comment in https://github.com/apache/seatunnel/blob/6e5737c1ec6c084af415b7ab7c456a98626dca8c/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/CommonOptions.java#L53



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284420996


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonDeserializationSchema.java:
##########
@@ -137,6 +140,7 @@ public void deserialize(ObjectNode jsonNode, Collector<SeaTunnelRow> out) throws
 
             JsonNode dataNode = jsonNode.get(FIELD_DATA);
             String op = jsonNode.get(FIELD_TYPE).asText();
+            JsonNode tsNode = jsonNode.get(FIELD_TS);

Review Comment:
   > So this value is milliseconds?
   
   yes



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2284442538


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -62,6 +67,15 @@ public byte[] serialize(SeaTunnelRow row) {
             String opType = rowKind2String(row.getRowKind());
             reuse.setField(0, new SeaTunnelRow[] {row});
             reuse.setField(1, opType);
+            if (!StringUtils.isEmpty(row.getTableId())) {
+                reuse.setField(2, TablePath.of(row.getTableId()).getDatabaseName());
+                reuse.setField(3, TablePath.of(row.getTableId()).getTableName());
+            }
+
+            if (row.getOptions() != null && row.getOptions().containsKey(EVENT_TIME.getName())) {
+                reuse.setField(4, row.getOptions().get(EVENT_TIME.getName()));

Review Comment:
   > Could you add some comment in
   > 
   > https://github.com/apache/seatunnel/blob/6e5737c1ec6c084af415b7ab7c456a98626dca8c/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/CommonOptions.java#L53
   
   i add it , and change metadata.md



-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#issuecomment-3190467014

   cc @wubx


-- 
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


Re: [PR] [Feature][json-format ] Improve maxwell_json,canal_json,debezium_json format add ts_ms and tableId [seatunnel]

Posted by "dyp12 (via GitHub)" <gi...@apache.org>.
dyp12 commented on code in PR #9701:
URL: https://github.com/apache/seatunnel/pull/9701#discussion_r2278157042


##########
seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/canal/CanalJsonSerializationSchema.java:
##########
@@ -88,9 +98,12 @@ private static SeaTunnelRowType createJsonRowType(SeaTunnelRowType databaseSchem
         // but we don't need them
         // and we don't need "old" , because can not support UPDATE_BEFORE,UPDATE_AFTER
         return new SeaTunnelRowType(
-                new String[] {"data", "type"},
+                new String[] {"data", "type", "tableId", "ts"},

Review Comment:
   > The cancel format is database and table fields, not tableId. Please refer https://docs.pingcap.com/zh/tidb/stable/ticdc-canal-json/#dml-event
   
   SeaTunnelRow do not have database and table fields, if use tableId to get db fields,may be get error data,remove it,only add ts field?



-- 
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