You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "yuqi1129 (via GitHub)" <gi...@apache.org> on 2026/08/10 12:02:14 UTC

Re: [PR] [#12272] feat(clickhouse): map ClickHouse Date32 to Gravitino DateType and verify Enum round-trip [gravitino]

yuqi1129 commented on code in PR #12275:
URL: https://github.com/apache/gravitino/pull/12275#discussion_r3749271738


##########
catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/converter/ClickHouseTypeConverter.java:
##########
@@ -162,8 +162,11 @@ public Type toGravitino(JdbcTypeBean typeBean) {
       case DATE:
         return Types.DateType.get();
       case DATE32:
-        // Date32 supports 1900-2299 vs Date's 1970-2149. Use ExternalType to preserve round-trip.
-        return Types.ExternalType.of(DATE32);
+        // Date32 supports 1900-2299 vs Date's 1970-2149-06-06. Map to DateType as a lossy
+        // downgrade: writing DateType yields Date (not Date32), and out-of-range Date32 values
+        // are silently saturated by ClickHouse (e.g. 1900-01-01 -> 1970-01-01). Use
+        // ExternalType("Date32") when lossless round-trip of the wider range is required.
+        return Types.DateType.get();

Review Comment:
   The only problem is that we can't tell the exact type when converting Gravitino `DateType`  to Clickhouse type. 



-- 
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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org