Skip to content

fix: emit explicit CAST for float literals in SQL compilation#11982

Closed
joaquinhuigomez wants to merge 1 commit into
ibis-project:mainfrom
joaquinhuigomez:fix/float-literal-cast
Closed

fix: emit explicit CAST for float literals in SQL compilation#11982
joaquinhuigomez wants to merge 1 commit into
ibis-project:mainfrom
joaquinhuigomez:fix/float-literal-cast

Conversation

@joaquinhuigomez

Copy link
Copy Markdown

Float literals were compiled without an explicit CAST, causing Postgres to interpret values like 0.5518 as numeric/decimal instead of double precision. Integer literals already received the correct CAST.

Adds a dtype.is_floating() check in the Postgres compiler's visit_NonNullLiteral that wraps finite float values in CAST(... AS DOUBLE PRECISION), matching the existing behavior for other typed literals.

Non-finite values (NaN, inf) are left to the base class handler which already produces the correct 'NaN'::DOUBLE PRECISION etc.

Closes #11947

Float literals like 0.5518 were compiled without a CAST, causing
Postgres to interpret them as numeric/decimal instead of
double precision.

Closes ibis-project#11947
@github-actions github-actions Bot added tests Issues or PRs related to tests sql Backends that generate SQL labels Mar 28, 2026
@joaquinhuigomez

Copy link
Copy Markdown
Author

Realized this needs more thorough testing against additional backends before submitting. Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sql Backends that generate SQL tests Issues or PRs related to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Literal floats execute as wrong type with postgres backend, leading to pyarrow error

1 participant