hutiefang76 opened a new issue, #12868:
URL: https://github.com/apache/seatunnel/issues/12868
### Search before asking
- [x] Searched open/closed issues and PRs for this objective. The original
metadata support in #9701 and update handling in #9805 do not clear missing
metadata between records.
### What happened
Reusing a Canal or Maxwell JSON serializer causes a row without metadata to
inherit the previous row's database, table and event timestamp.
A direct serializer reproduction uses the same four-column schema as the
existing format tests (`id INT`, `name STRING`, `description STRING`, `weight
FLOAT`):
```java
CanalJsonSerializationSchema serializer = new
CanalJsonSerializationSchema(rowType);
SeaTunnelRow first = new SeaTunnelRow(new Object[] {1, "alpha", "d1", 5.0f});
first.setTableId("db1.t1");
MetadataUtil.setEventTime(first, 1700000000000L);
SeaTunnelRow second = new SeaTunnelRow(new Object[] {2, "beta", "d2", 9.0f});
serializer.serialize(first);
byte[] output = serializer.serialize(second);
```
The second output still contains
`"database":"db1","table":"t1","ts":1700000000000`, although the second input
has neither a table ID nor an event time. Replacing the serializer with
`MaxWellJsonSerializationSchema` gives the same result. A fresh serializer
starts with null metadata.
The serializers reuse an output row and only write metadata fields when the
current input provides them. Missing metadata must clear those fields rather
than reuse another record's values. Both format regressions fail on current
dev; the first-row assertions confirm that provided metadata is otherwise
emitted correctly.
I will fix the per-record metadata reset in these two serializers and add
coverage to the existing Canal/Maxwell suites, including rows with only table
or timestamp metadata. Timestamp units, options and public APIs will stay
unchanged.
### SeaTunnel Version
Dev at `e2957d27afa29d4de4324cf642450757d865b902`.
### SeaTunnel Config
Not applicable: reproduced directly through the public format serializer API
above, without a connector or job.
### Running Command
JUnit reproduction against the JSON format module; both serializer cases
fail before the fix. No SeaTunnel job was run.
### Error Exception
```text
canal row B inherited the previous row's database:
{"old":null,"data":[{"id":2,"name":"beta","description":"d2","weight":9.0}],"type":"INSERT","database":"db1","table":"t1","ts":1700000000000}
maxwell row B inherited the previous row's database:
{"old":null,"data":{"id":2,"name":"beta","description":"d2","weight":9.0},"type":"insert","database":"db1","table":"t1","ts":1700000000000}
```
### Java or Scala Version
JDK 17.
### Are you willing to submit PR?
- [x] Yes, I am contributing this fix to Apache SeaTunnel.
### Code of Conduct
- [x] I agree to follow the project's Code of Conduct.
<sub>Reproduction and report prepared and posted by an AI assistant for
@hutiefang76.</sub>
--
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]