TobKed commented on a change in pull request #6780: [AIRFLOW-4899] Fix BQ Hook
- get_datasets_list uses pagination (#6780)
URL: https://github.com/apache/airflow/pull/6780#discussion_r356441189
##########
File path: airflow/gcp/hooks/bigquery.py
##########
@@ -1833,16 +1838,26 @@ def get_datasets_list(self, project_id: Optional[str]
= None) -> List:
}
]
"""
+
dataset_project_id = project_id if project_id else self.project_id
- try:
- datasets_list = self.service.datasets().list(
-
projectId=dataset_project_id).execute(num_retries=self.num_retries)['datasets']
- self.log.info("Datasets List: %s", datasets_list)
+ optional_params = {'all': all_datasets}
+ if max_results:
+ optional_params['maxResults'] = max_results
- except HttpError as err:
- raise AirflowException(
- 'BigQuery job failed. Error was: {}'.format(err.content))
+ request = self.service.datasets().list(
+ projectId=dataset_project_id,
+ **optional_params)
Review comment:
I wonder is this `optional_params` dictionary is required. I've checked how
it is done here:
`airflow.providers.google.marketing_platform.hooks.campaign_manager.GoogleCampaignManagerHook.list_reports`
and it is slightly cleaner. WDYT?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services