GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BigQuery, BigQuery Storage]: Add option to use BigQuery Storage API to download results in BigQuery DB-API · Issue #16 · googleapis/python-bigquery

This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

[BigQuery, BigQuery Storage]: Add option to use BigQuery Storage API to download results in BigQuery DB-API #16

Copy link
Copy link
Closed
#36
Closed
[BigQuery, BigQuery Storage]: Add option to use BigQuery Storage API to download results in BigQuery DB-API#16
#36
Copy link
Assignees
plamut
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@tswast
tswast
opened on Oct 14, 2019
Issue body actions

Is your feature request related to a problem? Please describe.

In projects like superset, that use the SQL Alchemy connector, it can be quite slow to download large query results. The BigQuery Storage API speeds this up for to_dataframe / pandas, but not when used via the DB-API / SQL Alchemy. See: googleapis/python-bigquery-sqlalchemy#41

Describe the solution you'd like

When creating a DB-API Connection, provide a way to supply a BQ Storage client, in addition to a BQ client. Use this client to download results for the relevant methods in the Cursor object.

Describe alternatives you've considered

Could have a use_bqstorage_api option, but this would be inconsistent with the current constructor, which expects a client.

/cc @yiga2

Reacted by Jacob Hayes

Activity

  1. tswast
    self-assigned this
    on Oct 14, 2019
  2. tswast
    assigned
    plamut
    and unassigned
    tswast
    on Jan 8, 2020
  3. tswast commented on Jan 8, 2020

    @tswast
    tswast
    on Jan 8, 2020
    ContributorAuthor
    More actions

    The proposal here is to add a bqstorage_client argument to the Connection class:

    https://github.com/googleapis/google-cloud-python/blob/b387134827dbc3be0e1b431201e0875798002fda/bigquery/google/cloud/bigquery/dbapi/connection.py#L21-L26

    Instead of always calling list_rows to fetch the query results

    https://github.com/googleapis/google-cloud-python/blob/b387134827dbc3be0e1b431201e0875798002fda/bigquery/google/cloud/bigquery/dbapi/cursor.py#L215

    attempt to call the BQ Storage API first. This can be modelled after to_dataframe, where an iterable over rows is abstracted away.

    https://github.com/googleapis/google-cloud-python/blob/b387134827dbc3be0e1b431201e0875798002fda/bigquery/google/cloud/bigquery/table.py#L1407-L1436

    Just as with to_dataframe, there will be cases where the BQ Storage API will fail, but tabledata.list will succeed, so we'll need to fallback to tabledata.list even when a BQ Storage API client is available.

    Changes from to_dataframe logic:

    • Request only a single stream, as the DB-API isn't well suited for multi-threaded reads.
    • Iterate over rows rather than pages. https://github.com/googleapis/google-cloud-python/blob/b387134827dbc3be0e1b431201e0875798002fda/bigquery_storage/google/cloud/bigquery_storage_v1beta1/reader.py#L146
  4. plamut
    transferred this issue fromgoogleapis/google-cloud-pythonon Feb 4, 2020
  5. product-auto-label
    added
    api: bigqueryIssues related to the googleapis/python-bigquery API.
    on Feb 4, 2020
  6. plamut
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Feb 4, 2020
  7. plamut
    closed this as completedin #36on Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @plamut
    plamut

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.