Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google provider - add project_id to GoogleBaseHook #23719

Conversation

raphaelauv
Copy link
Contributor

the BigQueryHook based on GoogleBaseHook do not accept an explicit project_id

this PR add this feature

@boring-cyborg boring-cyborg bot added area:providers provider:google Google (including GCP) related issues labels May 16, 2022
@raphaelauv raphaelauv changed the title google provder - add project_id to GoogleBaseHook google provider - add project_id to GoogleBaseHook May 16, 2022
@raphaelauv raphaelauv force-pushed the feature/add_explicit_project_id_to_bq_hook branch from f83f4a0 to 31a7fea Compare May 16, 2022 10:04
@mik-laj
Copy link
Member

mik-laj commented May 16, 2022

Any method that needs project ID uses the fallback_to_default_project_id decorator, so I'm not sure if we need another way to configure the project ID.

@staticmethod
def fallback_to_default_project_id(func: Callable[..., RT]) -> Callable[..., RT]:
"""
Decorator that provides fallback for Google Cloud project id. If
the project is None it will be replaced with the project_id from the
service account the Hook is authenticated with. Project id can be specified
either via project_id kwarg or via first parameter in positional args.
:param func: function to wrap
:return: result of the function call
"""

@raphaelauv
Copy link
Contributor Author

raphaelauv commented May 16, 2022

yes but I'm thinking about the hook itself , currently if I call get_client

I have to give the project_id myself, example :

    def execute(self, context):
        bq_hook = BigQueryHook(
            bigquery_conn_id=self.bigquery_conn_id,
            use_legacy_sql=self.use_legacy_sql,
            delegate_to=self.delegate_to,
            location=self.location,
            impersonation_chain=self.impersonation_chain,
        )

        conn = bq_hook.get_client(project_id=self.project_id, location=self.location)

        ...

@raphaelauv raphaelauv closed this May 16, 2022
@raphaelauv raphaelauv deleted the feature/add_explicit_project_id_to_bq_hook branch May 16, 2022 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants