AlexisCubilla opened a new pull request, #5097:
URL: https://github.com/apache/calcite/pull/5097

   ## Jira Link
   
   [CALCITE-7652](https://issues.apache.org/jira/browse/CALCITE-7652)
   
   ## Changes Proposed
   
   `MssqlSqlDialect` did not override `getCastSpec` for `TIMESTAMP`, so a CAST 
to
   `TIMESTAMP` was emitted with the ANSI type name `TIMESTAMP`. In SQL Server,
   `TIMESTAMP` is a deprecated synonym for `ROWVERSION` (a binary type), so the
   generated SQL was rejected:
   
       CAST or CONVERT: invalid attributes specified for type 'timestamp'
   
   This is commonly triggered by an implicit cast, e.g. comparing a `DATETIME`
   column (Calcite `TIMESTAMP(3)`) against `CURRENT_TIMESTAMP`.
   
   This PR maps, for SQL Server 2008+:
   - `TIMESTAMP` -> `DATETIME2`
   - `TIMESTAMP WITH LOCAL TIME ZONE` -> `DATETIMEOFFSET`
   
   preserving fractional-seconds precision. Other dialects are unaffected (they
   still emit `TIMESTAMP`, which is valid there).
   
   Added a `RelToSqlConverterTest` case asserting the generated MSSQL SQL is
   `CAST(... AS DATETIME2(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]

Reply via email to