Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@
"sourceUris": [DATA_SAMPLE_GCS_URL],
},
},
bucket=DATA_SAMPLE_GCS_BUCKET_NAME,
source_objects=[DATA_SAMPLE_GCS_OBJECT_NAME],
)
# [END howto_operator_bigquery_create_external_table]

Expand Down
11 changes: 7 additions & 4 deletions airflow/providers/google/cloud/operators/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,8 @@ class BigQueryCreateExternalTableOperator(BaseOperator):
def __init__(
self,
*,
bucket: str,
source_objects: List,
bucket: Optional[str] = None,
source_objects: Optional[List] = None,
destination_project_dataset_table: str = None,
table_resource: Optional[Dict[str, Any]] = None,
schema_fields: Optional[List] = None,
Expand Down Expand Up @@ -1142,11 +1142,14 @@ def __init__(
if not table_resource:
warnings.warn(
"Passing table parameters via keywords arguments will be deprecated. "
"Please use provide table definition using `table_resource` parameter."
"You can still use external `schema_object`. ",
"Please use provide table definition using `table_resource` parameter.",
DeprecationWarning,
stacklevel=2,
)
if not bucket:
raise ValueError("`bucket` is required when not using `table_resource`.")
if not source_objects:
raise ValueError("`source_objects` is required when not using `table_resource`.")
Comment on lines +1149 to +1152

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be TypeError IMO.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ValueError is more correct.

Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError.

This case is more of "wrong arguments" not "arguments types".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Tomek. Value error is good here.

if not source_format:
source_format = 'CSV'
if not compression:
Expand Down