You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/05/16 14:24:16 UTC

[GitHub] [airflow] olchas commented on a change in pull request #8858: Refactor BigQuery operators

olchas commented on a change in pull request #8858:
URL: https://github.com/apache/airflow/pull/8858#discussion_r426157502



##########
File path: airflow/providers/google/cloud/operators/bigquery.py
##########
@@ -1334,27 +1388,30 @@ class BigQueryUpdateDatasetOperator(BaseOperator):
     ui_color = BigQueryUIColors.DATASET.value
 
     @apply_defaults
-    def __init__(self,
-                 dataset_resource: dict,
-                 dataset_id: Optional[str] = None,
-                 project_id: Optional[str] = None,
-                 gcp_conn_id: str = 'google_cloud_default',
-                 delegate_to: Optional[str] = None,
-                 *args, **kwargs) -> None:
+    def __init__(
+        self,
+        dataset_resource: dict,
+        fields: Optional[List[str]] = None,

Review comment:
       Again, why not put `fields` as the last argument?

##########
File path: airflow/providers/google/cloud/operators/bigquery.py
##########
@@ -741,28 +747,38 @@ class BigQueryCreateEmptyTableOperator(BaseOperator):
                 https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#clustering.fields
     :type cluster_fields: list
     """
-    template_fields = ('dataset_id', 'table_id', 'project_id',
-                       'gcs_schema_object', 'labels', 'view')
+    template_fields = (
+        'dataset_id',
+        'table_id',
+        'project_id',
+        'gcs_schema_object',
+        'labels',
+        'view'
+    )
+
     ui_color = BigQueryUIColors.TABLE.value
 
     # pylint: disable=too-many-arguments
     @apply_defaults
-    def __init__(self,
-                 dataset_id: str,
-                 table_id: str,
-                 project_id: Optional[str] = None,
-                 schema_fields: Optional[List] = None,
-                 gcs_schema_object: Optional[str] = None,
-                 time_partitioning: Optional[Dict] = None,
-                 bigquery_conn_id: str = 'google_cloud_default',
-                 google_cloud_storage_conn_id: str = 'google_cloud_default',
-                 delegate_to: Optional[str] = None,
-                 labels: Optional[Dict] = None,
-                 view: Optional[Dict] = None,
-                 encryption_configuration: Optional[Dict] = None,
-                 location: Optional[str] = None,
-                 cluster_fields: Optional[List[str]] = None,
-                 *args, **kwargs) -> None:
+    def __init__(
+        self,
+        dataset_id: str,
+        table_id: str,
+        table_resource: Optional[Dict[str, Any]] = None,

Review comment:
       Why not put new argument `table_resource` at the end? This way we do not brake backward compatibility if someone was using positional arguments.

##########
File path: airflow/providers/google/cloud/operators/bigquery.py
##########
@@ -997,9 +1042,6 @@ def execute(self, context):
                 labels=self.labels,
                 encryption_configuration=self.encryption_configuration
             )
-        except HttpError as err:

Review comment:
       Is there no need to catch `Conflict` anymore? Are these errors ignored because of `exists_ok=True` argument of hooks' method `create_empty_table`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org