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

   ### What would you like to be improved?
   
   The SQL expression that produces "now in epoch milliseconds" from the 
database clock is inlined as a string literal in almost every SQL provider:
   
   - MySQL/H2 flavour `((UNIX_TIMESTAMP() * 1000.0) + EXTRACT(MICROSECOND FROM 
CURRENT_TIMESTAMP(3)) / 1000)` — **114 occurrences across 32 files**
   - PostgreSQL flavour `CAST(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP) * 1000 AS 
BIGINT)` — **107 occurrences across 31 files**
   
   Duplicating it this widely means a fix to the expression (for example a 
precision or dialect-compatibility problem) has to be applied in a hundred 
places, and it is easy to introduce a subtly different variant that only fails 
on one backend.
   
   #11739 added 
`org.apache.gravitino.storage.relational.mapper.provider.DatabaseTimeSQL`, 
which holds both flavours as `DatabaseTimeSQL.MYSQL` and 
`DatabaseTimeSQL.POSTGRESQL`, in the package shared by the `base`, `h2` and 
`postgresql` provider packages. Only the entity change log providers were 
migrated there, to keep that PR focused on its own fix.
   
   ### How should we improve?
   
   Replace the remaining inlined literals with `DatabaseTimeSQL.MYSQL` / 
`DatabaseTimeSQL.POSTGRESQL`.
   
   The change is mechanical and behaviour-preserving: each literal is 
byte-identical to the constant, so the generated SQL must not change. A 
reviewer can verify this by asserting the produced statements are unchanged 
before and after, and the existing provider and mapper tests cover the affected 
statements.
   
   Suggested scope: one PR for all providers, since splitting a mechanical 
rename adds review overhead without reducing risk.
   


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