Skip to content

refactor(bigframes): reduce code size of AI functions and tests#17055

Merged
sycai merged 4 commits into
mainfrom
sycai_ai_func_refactor
May 13, 2026
Merged

refactor(bigframes): reduce code size of AI functions and tests#17055
sycai merged 4 commits into
mainfrom
sycai_ai_func_refactor

Conversation

@sycai
Copy link
Copy Markdown
Contributor

@sycai sycai commented May 12, 2026

The changes include:

  • Make all optional parameters default to None, which reduces the length of compiled SQLs
  • "Upper" the parameters at the API layer if necessary, so that we don't need to repeat this logic in both compilers later
  • Make all optional parameters default to None in the operator definitions too, saving some lines in the unit tests

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 refactors AI operations to handle optional parameters more consistently by defaulting them to None and moving string normalization to an earlier stage using a new _upper_optional helper. It also updates type hints and literal values to uppercase to align with BigQuery expectations. The review feedback suggests avoiding shadowing built-in functions in the new helper and recommends expanding the use of Literal type hints for task_type and optimization_mode to further improve type safety and consistency across the codebase.

Comment thread packages/bigframes/bigframes/bigquery/_operations/ai.py Outdated
Comment thread packages/bigframes/bigframes/operations/ai_ops.py
Comment thread packages/bigframes/bigframes/operations/ai_ops.py
Comment thread packages/bigframes/bigframes/operations/ai_ops.py
sycai and others added 2 commits May 12, 2026 22:14
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sycai sycai requested review from TrevorBergeron and tswast May 13, 2026 00:34
@sycai sycai marked this pull request as ready for review May 13, 2026 00:35
@sycai sycai requested review from a team as code owners May 13, 2026 00:35
@sycai sycai merged commit bc8b76b into main May 13, 2026
31 checks passed
@sycai sycai deleted the sycai_ai_func_refactor branch May 13, 2026 17:12
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.

2 participants