Skip to content

Commit f92c089

Browse files
feat(bigframes): Support Expression objects in create_model options
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", using an expression that calls a function on a literal value (e.g. 0.1 * 10). Co-authored-by: tswast <247555+tswast@users.noreply.github.com>
1 parent 7ea8bf5 commit f92c089

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/bigframes/tests/unit/core/sql/test_ml.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ def test_create_model_expression_option(snapshot):
106106
# e.g. 0.1 * 10
107107
literal_expr = ex.ScalarConstantExpression(0.1, dtypes.FLOAT_DTYPE)
108108
multiplier_expr = ex.ScalarConstantExpression(10, dtypes.INT_DTYPE)
109-
math_expr = ex.OpExpression(op=numeric_ops.mul_op, inputs=(literal_expr, multiplier_expr))
109+
math_expr = ex.OpExpression(
110+
op=numeric_ops.mul_op, inputs=(literal_expr, multiplier_expr)
111+
)
110112

111113
sql = bigframes.core.sql.ml.create_model_ddl(
112114
model_name="my_model",

0 commit comments

Comments
 (0)