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

   ### Purpose of this pull request
   
   Closes #13710.
   
   `DebeziumRowConverter` decoded every textual DECIMAL as Debezium `precise` 
mode (base64 unscaled bytes). Connectors running with 
`decimal.handling.mode=string` send decimal literals, which either fail 
(`"123.45"`, dropped silently by the Kafka source) or decode as unrelated 
numbers (`"1234"` is also valid base64 and becomes -26588.24). The two 
encodings cannot be told apart from the text alone, so the source now says 
which one it receives.
   
   | Behaviour | Before | After |
   |---|---|---|
   | `"123.45"`, Debezium `string` mode | `Invalid bytes for Decimal field`; 
Kafka source drops the row | 123.45 with `debezium_decimal_handling_mode = 
string` |
   | `"1234"`, Debezium `string` mode | -26588.24, no error | 1234 with 
`debezium_decimal_handling_mode = string` |
   | `"MDk="`, Debezium `precise` mode (default) | 123.45 | unchanged |
   | `{"scale":0,"value":"AQ=="}` struct, JSON numbers, nulls | unchanged | 
unchanged |
   | Text that is not base64 in `precise` mode | `RuntimeException("Invalid 
bytes for Decimal field")` | `SeaTunnelJsonFormatException` naming the field, 
the value and the option to set |
   
   Changes:
   
   - `DebeziumDecimalHandlingMode` (`precise` default, `double`, `string`) 
mirrors Debezium's `decimal.handling.mode`; `DebeziumRowConverter` and 
`DebeziumJsonDeserializationSchema` get a constructor overload taking it, the 
old constructors keep `precise`.
   - `debezium_decimal_handling_mode` option on the Kafka source (both the 
plain and the `debezium_record_table_filter` dispatcher path) and the Amazon 
SQS source.
   - Docs EN/ZH: `debezium-json.md` (option table and a "Decimal handling" 
section), Kafka and AmazonSqs source option tables.
   
   A "parse as literal first, base64 otherwise" heuristic was considered and 
rejected: a `precise` value whose base64 is all digits (about 1 in 1700 
three-byte values) would silently be misread, so `precise` users would regress.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes: new optional source option `debezium_decimal_handling_mode` (default 
`precise`, existing behaviour). The parse error for non-base64 text in 
`precise` mode is now a `SeaTunnelJsonFormatException` with the field name and 
a hint.
   
   ### How was this patch tested?
   
   | Check | Result |
   |---|---|
   | New `DebeziumRowConverterTest` (string/double/precise modes, digits-only 
base64 ambiguity, error messages) | 4 of 6 fail on dev, all pass with the fix |
   | `DebeziumJsonSerDeSchemaTest#testStringDecimalHandlingMode` (deserializer, 
dropped-row behaviour with `ignoreParseErrors`) | passes |
   | `KafkaSourceConfigTest`, `AmazonSqsSourceReaderTest`: option reaches the 
deserializer end to end | pass |
   | `seatunnel-format-json`, `connector-kafka`, `connector-amazonsqs` unit 
suites, JDK 11 and 17 | 83 / 133 / 35, all green |
   | `spotless:check` | clean |
   
   ### Check list
   
   * [x] No new dependency
   * [x] Documentation updated 
(`docs/en|zh/connectors/formats/debezium-json.md`, 
`docs/en|zh/connectors/source/Kafka.md`, 
`docs/en|zh/connectors/source/AmazonSqs.md`)
   * [x] `incompatible-changes.md` not needed (default keeps current behaviour)
   * [x] Not a connector addition
   


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

Reply via email to