diqiu50 commented on code in PR #10534:
URL: https://github.com/apache/gravitino/pull/10534#discussion_r3193830279


##########
catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java:
##########
@@ -76,7 +76,23 @@ public Type toGravitino(JdbcTypeBean typeBean) {
             .map(Types.TimestampType::withTimeZone)
             .orElseGet(Types.TimestampType::withTimeZone);
       case NUMERIC:
-        return Types.DecimalType.of(typeBean.getColumnSize(), 
typeBean.getScale());
+        Integer columnSize = typeBean.getColumnSize();
+        Integer scale = typeBean.getScale();
+        // Unconstrained NUMERIC (no precision/scale) — PostgreSQL JDBC 
returns columnSize=0.
+        // Use ExternalType to preserve arbitrary-precision semantics (backed 
by BigDecimal).
+        if (columnSize == null || columnSize == 0) {
+          return Types.ExternalType.of(NUMERIC);
+        }
+        int effectiveScale = scale != null ? scale : 0;
+        // NUMERIC(P, 0) with small P can be represented as integer types for 
better performance.
+        if (effectiveScale == 0) {

Review Comment:
   Please explain these numbers



##########
catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java:
##########
@@ -76,7 +76,23 @@ public Type toGravitino(JdbcTypeBean typeBean) {
             .map(Types.TimestampType::withTimeZone)
             .orElseGet(Types.TimestampType::withTimeZone);
       case NUMERIC:
-        return Types.DecimalType.of(typeBean.getColumnSize(), 
typeBean.getScale());
+        Integer columnSize = typeBean.getColumnSize();
+        Integer scale = typeBean.getScale();
+        // Unconstrained NUMERIC (no precision/scale) — PostgreSQL JDBC 
returns columnSize=0.
+        // Use ExternalType to preserve arbitrary-precision semantics (backed 
by BigDecimal).
+        if (columnSize == null || columnSize == 0) {
+          return Types.ExternalType.of(NUMERIC);
+        }
+        int effectiveScale = scale != null ? scale : 0;
+        // NUMERIC(P, 0) with small P can be represented as integer types for 
better performance.
+        if (effectiveScale == 0) {
+          if (columnSize < 10) {

Review Comment:
   We are not a compute engine. Is it necessary to do that?  How can we recover 
NUMERIC(P, 0) after this conversion?



##########
catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/converter/PostgreSqlTypeConverter.java:
##########
@@ -76,7 +76,23 @@ public Type toGravitino(JdbcTypeBean typeBean) {
             .map(Types.TimestampType::withTimeZone)
             .orElseGet(Types.TimestampType::withTimeZone);
       case NUMERIC:
-        return Types.DecimalType.of(typeBean.getColumnSize(), 
typeBean.getScale());
+        Integer columnSize = typeBean.getColumnSize();
+        Integer scale = typeBean.getScale();
+        // Unconstrained NUMERIC (no precision/scale) — PostgreSQL JDBC 
returns columnSize=0.
+        // Use ExternalType to preserve arbitrary-precision semantics (backed 
by BigDecimal).
+        if (columnSize == null || columnSize == 0) {
+          return Types.ExternalType.of(NUMERIC);

Review Comment:
   We convert it to the ExternalType, so it does not work on the engine side.



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