Skip to content

Commit 68c6fdf

Browse files
authored
fix: ml.sql logic (#262)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent 5bdcc65 commit 68c6fdf

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

bigframes/ml/sql.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,12 @@ def create_model(
153153
) -> str:
154154
"""Encode the CREATE OR REPLACE MODEL statement for BQML"""
155155
source_sql = source_df.sql
156-
transform_sql = self.transform(*transforms) if transforms is not None else None
157-
options_sql = self.options(**options)
158156

159157
parts = [f"CREATE OR REPLACE MODEL {self._model_id_sql(model_ref)}"]
160-
if transform_sql:
161-
parts.append(transform_sql)
162-
if options_sql:
163-
parts.append(options_sql)
158+
if transforms:
159+
parts.append(self.transform(*transforms))
160+
if options:
161+
parts.append(self.options(**options))
164162
parts.append(f"AS {source_sql}")
165163
return "\n".join(parts)
166164

@@ -189,11 +187,10 @@ def create_imported_model(
189187
options: Mapping[str, Union[str, int, float, Iterable[str]]] = {},
190188
) -> str:
191189
"""Encode the CREATE OR REPLACE MODEL statement for BQML remote model."""
192-
options_sql = self.options(**options)
193190

194191
parts = [f"CREATE OR REPLACE MODEL {self._model_id_sql(model_ref)}"]
195-
if options_sql:
196-
parts.append(options_sql)
192+
if options:
193+
parts.append(self.options(**options))
197194
return "\n".join(parts)
198195

199196

0 commit comments

Comments
 (0)