Skip to content

Commit 58f647b

Browse files
committed
feat: Pass options as struct to ML.PREDICT and ML.GLOBAL_EXPLAIN
This change corrects the SQL generation for and to pass the options as a struct, which is the correct syntax. The snapshot tests have been updated to reflect these changes.
1 parent 03e46f9 commit 58f647b

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

GEMINI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Testing
44

5-
We use `pytest` to instrument our tests.
5+
We use `nox` to instrument our tests.
66

7-
- To test your changes, run unit tests with `pytest`:
7+
- To test your changes, run unit tests with `nox`:
88

99
```bash
1010
nox -r -s unit

bigframes/core/sql/ml.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ def predict(
189189
struct_options["trial_id"] = trial_id
190190

191191
sql = (
192-
f"SELECT * FROM ML.PREDICT(MODEL {googlesql.identifier(model_name)}, ({table}))"
192+
f"SELECT * FROM ML.PREDICT(MODEL {googlesql.identifier(model_name)}, ({table})"
193193
)
194194
sql += _build_struct_sql(struct_options)
195-
sql += "\n"
195+
sql += ")\n"
196196
return sql
197197

198198

@@ -238,9 +238,9 @@ def global_explain(
238238
if class_level_explain is not None:
239239
struct_options["class_level_explain"] = class_level_explain
240240

241-
sql = f"SELECT * FROM ML.GLOBAL_EXPLAIN(MODEL {googlesql.identifier(model_name)})"
241+
sql = f"SELECT * FROM ML.GLOBAL_EXPLAIN(MODEL {googlesql.identifier(model_name)}"
242242
sql += _build_struct_sql(struct_options)
243-
sql += "\n"
243+
sql += ")\n"
244244
return sql
245245

246246

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT * FROM ML.GLOBAL_EXPLAIN(MODEL `my_model`), STRUCT(true AS class_level_explain)
1+
SELECT * FROM ML.GLOBAL_EXPLAIN(MODEL `my_model`, STRUCT(true AS class_level_explain))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SELECT * FROM ML.PREDICT(MODEL `my_model`, (SELECT * FROM new_data)), STRUCT(true AS keep_original_columns)
1+
SELECT * FROM ML.PREDICT(MODEL `my_model`, (SELECT * FROM new_data), STRUCT(true AS keep_original_columns))

0 commit comments

Comments
 (0)