Skip to content

fix: ml.sql logic #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions bigframes/ml/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ def create_model(
) -> str:
"""Encode the CREATE OR REPLACE MODEL statement for BQML"""
source_sql = source_df.sql
transform_sql = self.transform(*transforms) if transforms is not None else None
options_sql = self.options(**options)

parts = [f"CREATE OR REPLACE MODEL {self._model_id_sql(model_ref)}"]
if transform_sql:
parts.append(transform_sql)
if options_sql:
parts.append(options_sql)
if transforms:
parts.append(self.transform(*transforms))
if options:
parts.append(self.options(**options))
parts.append(f"AS {source_sql}")
return "\n".join(parts)

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

parts = [f"CREATE OR REPLACE MODEL {self._model_id_sql(model_ref)}"]
if options_sql:
parts.append(options_sql)
if options:
parts.append(self.options(**options))
return "\n".join(parts)


Expand Down