laserninja opened a new issue, #13160:
URL: https://github.com/apache/gravitino/issues/13160

   ### Version
   
   main branch (reproduced at 5a9ee9aba; relevant code checked against upstream 
9d6a881698)
   
   ### Describe what's wrong
   
   Valid PostgreSQL constrained NUMERIC declarations can prevent table loading. 
The converter passes their metadata into Gravitino DecimalType, whose precision 
and scale limits are narrower. NUMERIC(10,2) works as a control.
   
   ### Error message and/or stacktrace
   
   ```text
   NUMERIC(39,0): IllegalArgumentException: Decimal precision must be in 
range[1, 38]: precision: 39
   NUMERIC(2,-3): IllegalArgumentException: Decimal scale must be in range [0, 
precision (2)]: scala: 2045
   NUMERIC(3,5): IllegalArgumentException: Decimal scale must be in range [0, 
precision (3)]: scala: 5
   ```
   
   ### How to reproduce
   
   Create separate tables with columns `NUMERIC(39,0)`, `NUMERIC(2,-3)`, and 
`NUMERIC(3,5)`. Insert respectively `123456789012345678901234567890123456789`, 
`12345`, and `0.00123`. PostgreSQL accepts all three. Call 
PostgreSqlTableOperations.load for each table: each fails as shown. Expected: 
load the table and preserve unsupported numeric declarations through an 
external type instead of narrowing or rejecting them.
   
   ### Additional context
   
   Reproduced against PostgreSQL 18 with JDBC 42.7.11; this driver reports the 
negative scale in encoded form as 2045. This is distinct from the unconstrained 
NUMERIC issue #13040 and fix #13042. Validate precision/scale representability, 
preserve unsupported declarations and correctly obtain/decode negative scale 
metadata. PostgreSQL documents these valid declarations at 
https://www.postgresql.org/docs/current/datatype-numeric.html .
   
   Source: 
`catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java:79`.
   


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