xiedeyantu opened a new pull request, #21445:
URL: https://github.com/apache/datafusion/pull/21445

   ## Which issue does this PR close?
   
   - No linked issue.
   
   ## Rationale for this change
   
   DataFusion's PostgreSQL unparser should emit PostgreSQL-compatible SQL for 
integer casts.`Int8` was still being rendered as `TINYINT`, which is not valid 
PostgreSQL syntax. This change makes PostgreSQL output `SMALLINT` instead.
   
   ## What changes are included in this PR?
   
   - Added an `int8_cast_dtype` hook to the SQL unparser dialect abstraction.
   - Updated `PostgreSqlDialect` to map `Int8` to `SMALLINT`.
   - Routed `DataType::Int8` unparsing through the dialect hook.
   - Added a regression test covering `select cast(3 as tinyint)]` with 
PostgreSQL unparser output.
   
   ## Are these changes tested?
   
   - Yes. Ran:
     - `cargo test -p datafusion-sql --test sql_integration 
cases::plan_to_sql::test_cast_to_tinyint -- --exact`
   - The test passes.
   
   ## Are there any user-facing changes?
   
   - Yes. PostgreSQL dialect SQL generation now renders `CAST(... AS SMALLINT)` 
for `Int8` values instead of `CAST(... AS TINYINT)`.


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to