Skip to content

Commit

Permalink
ignores table options on ALTER TABLE (#1306)
Browse files Browse the repository at this point in the history
* ignores table options on ALTER TABLE

* Split OPTION alter test

Signed-off-by: Marcel Coetzee <[email protected]>

---------

Signed-off-by: Marcel Coetzee <[email protected]>
Co-authored-by: Marcel Coetzee <[email protected]>
  • Loading branch information
rudolfix and Pipboyguy authored May 8, 2024
1 parent 3c00ecd commit a6fab16
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 43 deletions.
5 changes: 4 additions & 1 deletion dlt/destinations/impl/bigquery/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ def _get_table_update_sql(
return sql

if generate_alter:
raise NotImplementedError("Update table options not yet implemented.")
logger.info(
f"Table options for {table_name} are not applied on ALTER TABLE. Make sure that you"
" set the table options ie. by using bigquery_adapter, before it is created."
)
else:
sql[0] += (
"\nOPTIONS ("
Expand Down
6 changes: 3 additions & 3 deletions dlt/destinations/impl/bigquery/bigquery_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def bigquery_adapter(
raise ValueError(
"`table_description` must be string representing BigQuery table description."
)
additional_table_hints |= {TABLE_DESCRIPTION_HINT: table_description} # type: ignore[operator]
additional_table_hints[TABLE_DESCRIPTION_HINT] = table_description

if table_expiration_datetime:
if not isinstance(table_expiration_datetime, str):
Expand All @@ -146,7 +146,7 @@ def bigquery_adapter(
parsed_table_expiration_datetime = parser.parse(table_expiration_datetime).replace(
tzinfo=timezone.utc
)
additional_table_hints |= {TABLE_EXPIRATION_HINT: parsed_table_expiration_datetime} # type: ignore[operator]
additional_table_hints[TABLE_EXPIRATION_HINT] = parsed_table_expiration_datetime
except ValueError as e:
raise ValueError(f"{table_expiration_datetime} could not be parsed!") from e

Expand All @@ -156,7 +156,7 @@ def bigquery_adapter(
"BigQuery streaming insert can only be used with `append` write_disposition, while "
f"the given resource has `{data.write_disposition}`."
)
additional_table_hints |= {"x-insert-api": insert_api} # type: ignore[operator]
additional_table_hints["x-insert-api"] = insert_api

if column_hints or additional_table_hints:
resource.apply_hints(columns=column_hints, additional_table_hints=additional_table_hints)
Expand Down
Loading

0 comments on commit a6fab16

Please sign in to comment.