Skip to content

feat(bigframes): Support Expression objects in create_model options#16606

Open
tswast wants to merge 1 commit intomainfrom
feat-bigframes-create-model-expression-options-15193413976404138758
Open

feat(bigframes): Support Expression objects in create_model options#16606
tswast wants to merge 1 commit intomainfrom
feat-bigframes-create-model-expression-options-15193413976404138758

Conversation

@tswast
Copy link
Copy Markdown
Contributor

@tswast tswast commented Apr 9, 2026

Allows users to specify BigFrames Expression objects as values within the options dictionary when calling create_model. These values are compiled natively to their scalar SQL representation in the resulting CREATE MODEL BigQuery DDL. Snapshot tests confirm the translation logic.


PR created automatically by Jules for task 15193413976404138758 started by @tswast

This change allows the `options` parameter of `bigframes.bigquery._operations.ml.create_model` to accept BigFrames `Expression` objects. These expressions are compiled to SQL scalar expressions and included in the generated `CREATE MODEL` DDL statement.

- Added `bigframes.core.expression.Expression` type support in the `options` dict.
- Updated `create_model_ddl` to handle compiling expressions using `expression_compiler`.
- Added `test_create_model_expression_option` snapshot test to verify the generated "golden SQL".

Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
@tswast tswast requested a review from a team as a code owner April 9, 2026 23:14
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@tswast tswast requested review from a team as code owners April 9, 2026 23:14
@tswast tswast requested review from TrevorBergeron and removed request for a team April 9, 2026 23:14
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 enables the use of expressions within model options by updating the type hints and implementing logic to compile and render these expressions into SQL. I have reviewed the changes and have no further feedback to provide, though I recommend moving the local import in the test file to the top-level module to align with standard Python practices.



def test_create_model_expression_option(snapshot):
import bigframes.core.expression as ex
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.

medium

For improved code readability and adherence to the PEP 8 style guide, it's best to place imports at the top of the file. Please move this import to the top-level of the module.

References
  1. PEP 8, the style guide for Python code, recommends that all imports should be at the top of the file. This makes it easy to see what modules the script requires. Imports within functions are generally discouraged, except for cases like avoiding circular dependencies or for optional imports, which does not seem to be the case here. (link)

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