laserninja commented on code in PR #13163:
URL: https://github.com/apache/gravitino/pull/13163#discussion_r4125852283
##########
catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java:
##########
@@ -86,7 +86,16 @@ public Type toGravitino(JdbcTypeBean typeBean) {
if (columnSize == null || columnSize == 0) {
return Types.ExternalType.of(NUMERIC);
}
- return Types.DecimalType.of(columnSize, scale == null ? 0 : scale);
+ int numericScale = scale == null ? 0 : scale;
+ // PostgreSQL stores scale as a signed 11-bit value. JDBC metadata can
expose the
+ // unsigned representation, for example 2045 for NUMERIC(2, -3).
Review Comment:
Added versioned links beside the decoding logic. PostgreSQL's
[numeric_typmod_scale](https://github.com/postgres/postgres/blob/REL_15_0/src/backend/utils/adt/numeric.c#L851-L864)
sign-extends an 11-bit scale, whereas pgjdbc 42.7.11
[TypeInfoCache.getScale](https://github.com/pgjdbc/pgjdbc/blob/REL42.7.11/pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java#L863-L875)
returns the low 16 bits unsigned. This explains the observed 2045 for scale -3.
--
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]