[AIRFLOW-4899] Fix BQ Hook - get_datasets_list uses pagination (#6780)#6780
[AIRFLOW-4899] Fix BQ Hook - get_datasets_list uses pagination (#6780)#6780benjamingrenier wants to merge 1 commit intoapache:masterfrom
Conversation
9a86a72 to
1899b52
Compare
…e#6780) Fix CloudBaseHook decorator
1899b52 to
183bf8b
Compare
|
@benjamingrenier could you fix link to the Jira issue in the description please? |
TobKed
left a comment
There was a problem hiding this comment.
Good job @benjamingrenier :) . I've left some comments
|
|
||
| def get_datasets_list(self, project_id: Optional[str] = None) -> List: | ||
| @CloudBaseHook.catch_http_exception | ||
| def get_datasets_list(self, project_id=None, max_results=None, all_datasets=False): |
There was a problem hiding this comment.
Could you add type annotations, please? I think it is good idea to keep them :)
| projectId=dataset_project_id, | ||
| **optional_params) | ||
|
|
||
| datasets_list = [] |
There was a problem hiding this comment.
I think you could just use datasets here and add type. What do you think?
| 'BigQuery job failed. Error was: {}'.format(err.content)) | ||
| request = self.service.datasets().list( | ||
| projectId=dataset_project_id, | ||
| **optional_params) |
There was a problem hiding this 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?
| self.assertEqual(result, expected_result['datasets']) | ||
| mock_service = mock.Mock() | ||
| cursor = hook.BigQueryBaseCursor(mock_service, project_id) | ||
| mock_service.datasets.return_value.list.return_value.execute.return_value = { |
There was a problem hiding this comment.
I think you could check here by using assert_called_once_with with what parameters list method was called.
Codecov Report
@@ Coverage Diff @@
## master #6780 +/- ##
=========================================
- Coverage 84.53% 84.23% -0.3%
=========================================
Files 672 672
Lines 38153 38159 +6
=========================================
- Hits 32252 32144 -108
- Misses 5901 6015 +114
Continue to review full report at Codecov.
|
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
@benjamingrenier I just ran into the same issue and found that you were apparently trying to get this fix merged since July 2019 (#5565). Would you be willing to pick this up again? Can I help? |
|
@Mofef Can you create a new PR? I am happy to help with the review. |
|
Sure, I'd like to try that. Is it ok to start with forking from what @benjamingrenier already achieved and addressing the previous review comments? |
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation