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

Use original Client's client_info in _ensure_bqstorage_client to create BigQueryReadClient #1961

Open
b-schmeling opened this issue Jun 19, 2024 · 0 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.

Comments

@b-schmeling
Copy link

b-schmeling commented Jun 19, 2024

Problem

If I set the user_agent in the client_info in a BigQueryClient, the resultant storage client from _ensure_bqstorage_client does not have the user agent I set.

This is visible in the code here:

def _ensure_bqstorage_client(
        self,
        bqstorage_client: Optional[
            "google.cloud.bigquery_storage.BigQueryReadClient"
        ] = None,
        client_options: Optional[google.api_core.client_options.ClientOptions] = None,
        client_info: Optional[
            "google.api_core.gapic_v1.client_info.ClientInfo"
        ] = DEFAULT_BQSTORAGE_CLIENT_INFO,
    ) -> Optional["google.cloud.bigquery_storage.BigQueryReadClient"]:
       ...

        if bqstorage_client is None:  # pragma: NO COVER
            bqstorage_client = bigquery_storage.BigQueryReadClient(
                credentials=self._credentials,
                client_options=client_options,
                client_info=client_info,  # type: ignore  # (None is also accepted)
            )

Solution

For _ensure_bqstorage_client to default to using the original client's client_info if no client_info is provided in the params.

The only part of the client_info that I really need in both clients is the user_agent, so alternatively I would be fully satisfied if just the user agent were propagated to the storage client.

Alternatives

For now, I believe I will have to manually create the bqstorage client with my own client_info.

Additional context

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Jun 19, 2024
@shollyman shollyman assigned Linchin and unassigned obada-ab Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API.
Projects
None yet
Development

No branches or pull requests

3 participants