feat(bigframes): Support Expression objects in create_model options#16606
feat(bigframes): Support Expression objects in create_model options#16606
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
- 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)
Allows users to specify BigFrames
Expressionobjects as values within theoptionsdictionary when callingcreate_model. These values are compiled natively to their scalar SQL representation in the resultingCREATE MODELBigQuery DDL. Snapshot tests confirm the translation logic.PR created automatically by Jules for task 15193413976404138758 started by @tswast