jackylee-ch opened a new pull request, #10361:
URL: https://github.com/apache/paimon/pull/10361

   ### Purpose
   
   `PostgresRecordParser.extractFieldType` built `DataTypes.DECIMAL(precision, 
scale)`
   directly from the Debezium `connect.decimal` metadata with no range check.
   PostgreSQL `numeric` allows a precision up to 1000 (and, since PG 15, a scale
   outside `[0, precision]`), while Paimon `DECIMAL` requires `precision <= 38` 
and
   `0 <= scale <= precision`. A column such as `numeric(50, 2)` therefore 
crashed the
   `postgres_sync_table` / `postgres_sync_database` job on the very first 
record with an
   `IllegalArgumentException` from the `DecimalType` constructor.
   
   The JDBC schema path (`PostgresTypeUtils#toDataType`) already degrades 
out-of-range
   numerics to STRING. This reuses its `isDecimalOutOfRange` predicate from the 
record
   path so the two paths agree, instead of one creating the column as STRING 
while the
   other crashes. The decimal value is already carried as a plain numeric 
string (the
   record path validates it with `new BigDecimal(...)`), so STRING storage 
preserves it
   faithfully.
   
   ### Tests
   
   `PostgresRecordParserTest#testOutOfRangeDecimalPrecisionMapsToString` feeds a
   `numeric(50, 2)` Debezium event and asserts the column maps to STRING;
   `testInRangeDecimalMapsToDecimal` asserts an in-range `numeric(10, 2)` still 
maps to
   `DECIMAL(10, 2)` (no over-degradation).
   
   ### API and Format
   
   No change.
   
   ### Documentation
   
   No change.
   


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