Skip to content

fix(bigframes): Fix IsInOp literal bug with sqlglot#17356

Open
TrevorBergeron wants to merge 2 commits into
mainfrom
tbergeron_sqlglot_isin_literals
Open

fix(bigframes): Fix IsInOp literal bug with sqlglot#17356
TrevorBergeron wants to merge 2 commits into
mainfrom
tbergeron_sqlglot_isin_literals

Conversation

@TrevorBergeron
Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces sge.convert with sql.literal when compiling comparison operations, and adds unit tests and snapshots to verify the handling of various float literals (such as infinity, NaN, and scientific notation). The review feedback correctly points out that using sql.literal will likely raise a NameError because the sql module is not imported, and suggests using sge.literal instead for consistency and safety.

if must_upcast_bools and dtype == dtypes.BOOL_DTYPE:
value = int(value)
values.append(sge.convert(value))
values.append(sql.literal(value))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using sql.literal may raise a NameError if the sql module or alias is not imported in this file. Since sqlglot.expressions is already imported and used as sge (e.g., sge.Expression and sge.convert), it is safer and more consistent to use sge.literal instead.

Suggested change
values.append(sql.literal(value))
values.append(sge.literal(value))

@TrevorBergeron TrevorBergeron marked this pull request as ready for review June 3, 2026 01:15
@TrevorBergeron TrevorBergeron requested review from a team as code owners June 3, 2026 01:15
@TrevorBergeron TrevorBergeron requested review from GarrettWu and removed request for a team June 3, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant