hutiefang76 opened a new issue, #12869:
URL: https://github.com/apache/seatunnel/issues/12869

   ### Search before asking
   
   - [x] Searched open/closed issues and PRs for `hasDecimalType` and JSON 
decimal precision; no same-purpose fix found.
   
   ### What happened
   
   JSON parsing loses digits when the schema's DECIMAL values occur only inside 
arrays. With `amounts ARRAY<DECIMAL(38,20)>`, input 
`{"amounts":[3.14159265358979323846]}` yields `3.141592653589793`. The same 
value in a scalar DECIMAL remains exact. `ARRAY<ARRAY<DECIMAL>>` and 
`ARRAY<ROW<DECIMAL>>` also lose precision; adding a scalar DECIMAL sibling 
makes those array values exact.
   
   Reproduced on dev in the existing `JsonRowDataSerDeSchemaTest`: 32 tests, 
three expected precision failures, zero errors/skips. Scalar, scalar-sibling 
and ordinary-array controls pass.
   
   `hasDecimalType` checks `CompositeType` children, but `ArrayType` is not a 
`CompositeType`, so the decimal-preserving mapper setting is not enabled for 
these schemas. I will extend that check to array elements and cover nested 
arrays and rows, without changing APIs, schema types or options.
   
   That mapper setting applies to the whole input document, as it already does 
with scalar DECIMAL schemas. After the fix, a bare numeric JSON token mapped to 
a STRING sibling may retain more digits in an array-only DECIMAL schema too. I 
will document this in English/Chinese and the upgrade notes. Quoted strings and 
schemas without DECIMAL remain unchanged. This scope is the plain JSON schema 
traversal; it does not change Kafka-Connect mapper setup.
   
   ### SeaTunnel Version
   
   Dev at `e2957d27afa29d4de4324cf642450757d865b902`.
   
   ### SeaTunnel Config
   
   Direct `JsonDeserializationSchema` test with `ArrayType.of(new 
DecimalType(38, 20))`; no connector or job was run.
   
   ### Running Command
   
   ```sh
   ./mvnw -pl seatunnel-formats/seatunnel-format-json -am \
     -Dtest=JsonRowDataSerDeSchemaTest -Dsurefire.failIfNoSpecifiedTests=false 
package
   ```
   
   ### Error Exception
   
   ```text
   Tests run: 32, Failures: 3, Errors: 0, Skipped: 0
   DECIMAL element of ARRAY<DECIMAL> must keep the exact input precision
   DECIMAL element of ARRAY<ARRAY<DECIMAL>> must keep the exact input precision
   DECIMAL field of ROW inside ARRAY<ROW<DECIMAL>> must keep the exact precision
   ```
   
   ### Java or Scala Version
   
   JDK 17.0.18, macOS ARM64.
   
   ### Are you willing to submit PR?
   
   - [x] Yes, I am contributing this fix to Apache SeaTunnel.
   
   ### Code of Conduct
   
   - [x] I agree to follow this 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]

Reply via email to