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

   ### Version
   
   main branch (source inspected at `ebf08d6659b111964e84665557485995e808c9f5`)
   
   ### Describe what's wrong
   
   The MySQL catalog cannot load metadata for an existing table whose TIMESTAMP 
column has a zero-date default such as `0000-00-00 00:00:00`. Such defaults can 
exist in legacy MySQL schemas or schemas created with permissive SQL modes.
   
   `MysqlColumnDefaultValueConverter.toGravitino()` parses TIMESTAMP/DATETIME 
defaults using `LocalDateTime.parse()`. When a zero-date default is 
encountered, it throws an `IllegalArgumentException` instead of representing 
the default without losing its original value.
   
   In a downstream deployment, granting table privileges also failed with the 
same error when the operation needed to resolve the table metadata. The 
upstream finding here is based on source inspection; I have not rerun the 
reproduction on an upstream main build.
   
   ### Error message and/or stacktrace
   
   ```text
   IllegalArgumentException: Unable to parse datetime value: 0000-00-00 00:00:00
   ```
   
   ### How to reproduce
   
   Suggested minimal reproduction on a MySQL version that permits zero-date 
defaults:
   
   1. In a test MySQL session, use a permissive SQL mode and create the table:
   
      ```sql
      SET SESSION sql_mode = '';
      CREATE DATABASE IF NOT EXISTS zero_date_repro;
      CREATE TABLE zero_date_repro.example_table (
        id BIGINT NOT NULL PRIMARY KEY,
        updated_at TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'
      );
      ```
   
   2. Register a MySQL catalog pointing to this instance.
   3. Load `zero_date_repro.example_table` through Gravitino.
   
   Expected: table metadata can be loaded while preserving the source default 
expression, even if it cannot be represented by a Java temporal literal.
   
   Actual behavior observed downstream: metadata resolution fails with the 
exception above. No table rows are needed to encounter the problematic column 
default.
   
   ### Additional context
   
   The relevant upstream code is:
   
   
https://github.com/apache/gravitino/blob/ebf08d6659b111964e84665557485995e808c9f5/catalogs/catalog-jdbc-mysql/src/main/java/org/apache/gravitino/catalog/mysql/converter/MysqlColumnDefaultValueConverter.java
   
   A possible approach is to preserve MySQL zero-date defaults as an 
`UnparsedExpression` rather than throwing or silently converting them to 
NULL/current time. Regression coverage could include zero-date 
TIMESTAMP/DATETIME defaults, fractional-second variants, and DATE defaults, 
while retaining existing behavior for valid temporal literals and 
CURRENT_TIMESTAMP expressions.
   
   This concerns parsing column-default metadata, rather than converting 
zero-date values in result-set rows.
   


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