gcloud-aio-bigquery is an asynchronous Python client for Google Cloud BigQuery, built on `asyncio` and `aiohttp`. It's part of the `gcloud-aio-*` family, providing an asynchronous HTTP implementation of Google Cloud client libraries. The current version is 7.1.0 and it maintains an active release cadence.
Install & Compatibility
Where this runs
tested against v7.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BigQuery
✓ from gcloud.aio.bigquery import BigQuery
✗ from gcloud.aio.bigquery import BigQuery
This quickstart demonstrates how to initialize the `BigQuery` client, authenticate using `gcloud-aio-auth`, and execute a simple SQL query against a public BigQuery dataset. Ensure your `GOOGLE_CLOUD_PROJECT` environment variable is set to your Google Cloud project ID, and `GOOGLE_APPLICATION_CREDENTIALS` points to your service account key file for local execution.
import asyncio
import os
import aiohttp
from gcloud.aio.auth import Token
from gcloud.aio.bigquery import BigQuery
async def main():
# Ensure GOOGLE_CLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS
# are set in your environment for authentication.
project = os.environ.get('GOOGLE_CLOUD_PROJECT', 'your-gcp-project-id') # Replace with your project ID
async with aiohttp.ClientSession() as session:
# Obtain Google Cloud credentials token
token = await Token(session=session).get()
# Initialize BigQuery client
client = BigQuery(project=project, session=session, token=token)
query = """
SELECT name, SUM(number) as total_babies
FROM `bigquery-public-data.usa_names.usa_1910_2013`
WHERE state = 'TX'
GROUP BY name
ORDER BY total_babies DESC
LIMIT 5
"""
print(f"Executing query for project: {project}")
job_id, result = await client.query_and_wait(query)
print(f"Query Job ID: {job_id}")
print("Top 5 baby names in Texas (1910-2013):")
for row in result['rows']:
print(f"- {row['name']}: {row['total_babies']}")
if __name__ == "__main__":
asyncio.run(main())
Debug
Known issues
gotchaThe `gcloud-aio-bigquery` library currently does not support deleting rows from a table via its API. Users requiring this functionality may need to use alternative methods like the standard `google-cloud-bigquery` library or BigQuery's DML statements directly.fixUse BigQuery DML statements (e.g., `DELETE FROM ... WHERE ...`) via the client's query method, or consider using the synchronous `google-cloud-bigquery` client for direct `delete` API calls if available there.
affects: All versions
gotchaThere can be confusion between `gcloud-aio-*` (asynchronous) and `gcloud-rest-*` (synchronous) client libraries, as they share a codebase and similar naming conventions. Additionally, the main client classes within `gcloud.aio.<service_name>` modules may not be directly exposed at the top level of the service module (e.g., `gcloud.aio.bigquery`), requiring deeper imports.fixAlways explicitly import from the correct full path for the client class. For `gcloud-aio-*` clients, this often means `from gcloud.aio.<service_name>.<service_name> import <ClientClassName>` (e.g., `from gcloud.aio.bigquery.bigquery import BigqueryClient`), and for `gcloud-rest-*` clients, `from gcloud.rest.<service_name> import <ClientClassName>`. Consult the specific library's documentation or source code for exact import paths.
affects: All versions
gotchaThe `query_response_to_dict` utility may raise exceptions when processing nullable integer fields that contain `None` values. This can lead to data parsing errors for queries returning sparse data.fixWhen dealing with nullable fields, especially integers, implement robust error handling or explicitly cast/check for `None` values before processing. Consider inspecting the raw `result` structure before using helper functions if this issue occurs.
affects: Prior to 7.1.0, potentially still present
gotchaOverusing `SELECT *` in BigQuery queries can significantly increase query costs and execution time, as BigQuery charges based on the amount of data scanned. This is a fundamental BigQuery best practice that applies to `gcloud-aio-bigquery` as well.fixAlways specify only the columns you need in your `SELECT` statements. Use `LIMIT` and `WHERE` clauses effectively to reduce data scanned.
affects: All versions
gotchaThe `BigQuery` client class cannot be imported directly using `from gcloud.aio.bigquery import BigQuery`. The primary client class might be named differently (e.g., `Client` or `BigqueryClient`) or reside in a deeper submodule within `gcloud.aio.bigquery`.fixVerify the exact class name and import path for the BigQuery client. Common patterns for `gcloud-aio` libraries include importing `Client` (e.g., `from gcloud.aio.bigquery import Client`) or `BigqueryClient` from a submodule (e.g., `from gcloud.aio.bigquery.client import BigqueryClient`). Refer to the library's documentation for the correct import statement.
affects: All versions
Audit
Dependencies
aiohttprequiredCore HTTP client library for asynchronous operations.
gcloud-aio-authrequiredProvides asynchronous authentication mechanisms for Google Cloud services.