Skip to content

feat(bigframes): update ai.if_() params to match the SQL version#16857

Draft
sycai wants to merge 5 commits intomainfrom
sycai_ai_if_update
Draft

feat(bigframes): update ai.if_() params to match the SQL version#16857
sycai wants to merge 5 commits intomainfrom
sycai_ai_if_update

Conversation

@sycai
Copy link
Copy Markdown
Contributor

@sycai sycai commented Apr 28, 2026

Reference: https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/bigqueryml-syntax-ai-if

I left out the embeddings param to keep things simple. It will be introduced later.

@sycai sycai requested review from a team as code owners April 28, 2026 22:33
@sycai sycai requested review from GarrettWu and removed request for a team April 28, 2026 22:33
@sycai sycai marked this pull request as draft April 28, 2026 22:35
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 adds endpoint, optimization_mode, and max_error_ratio parameters to the ai.if_ function, updating the core operations, SQL compilation, and tests accordingly. The review feedback identifies a conflict between default parameter values that could lead to invalid BigQuery requests, potential null pointer exceptions during SQL generation, and an incorrect literal value used in a test case.

Comment thread packages/bigframes/bigframes/bigquery/_operations/ai.py
result = bbq.ai.if_(prompt)
result = bbq.ai.if_(
prompt,
optimization_mode="maximize_quality",
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

The value "maximize_quality" is not a valid option for optimization_mode. Based on the Literal definition in the function signature and the BigQuery ML documentation, this should be "maximize_performance".

Suggested change
optimization_mode="maximize_quality",
optimization_mode="maximize_performance",

sycai and others added 3 commits April 28, 2026 15:48
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…ai_ops.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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