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

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   Two columns in the PostgreSQL catalog are reported with types that do not 
describe the data the source column can hold.
   
   1. A `NUMERIC` declared without precision and scale is reported as 
`decimal(38,18)`. PostgreSQL accepts up to 131072 digits before and 16383 
digits after the decimal point for such a column, and its precision and scale 
vary per row. The reported type claims 20 integer digits and 18 fractional 
digits that the source never declared, so a consumer that trusts it truncates 
or overflows on data PostgreSQL accepts. Constrained `NUMERIC(p, s)` is handled 
correctly.
   
   2. Array columns are reported with `containsNull: false`. PostgreSQL array 
elements always accept NULL and cannot be declared otherwise, so `containsNull: 
false` is never a true statement about a PostgreSQL array column.
   
   ### Error message and/or stacktrace
   
   No exception is raised. Both types are reported silently:
   
   ```
   ["c_numeric_nodef", "decimal(38,18)"]
   ["c_int_array",     
{"type":"list","containsNull":false,"elementType":"integer"}]
   ```
   
   ### How to reproduce
   
   Against PostgreSQL 16.6 with a `jdbc-postgresql` catalog:
   
   ```sql
   CREATE TABLE type_probe (c_numeric_nodef NUMERIC, c_int_array INTEGER[]);
   INSERT INTO type_probe VALUES
     (123456789012345678901234567890.123456789012345678901234567890, 
ARRAY[1,NULL,3]);
   ```
   
   PostgreSQL stores both values intact. Load the table through the catalog and 
compare the reported column types with the values above.
   
   ### Additional context
   
   Observed on 1.3.0-rc2. The rest of the PostgreSQL type map is in good shape: 
unmappable types return `external` carrying their source spelling, and 
precision is preserved on every constrained numeric.
   
   Reporting unconstrained `NUMERIC` as the external type `numeric` requires 
the Trino, Spark and Flink connectors to read an external type as a string, 
otherwise a single such column fails the type conversion of the whole table.
   


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