Skip to content

Implement BigQuery Driver #168

Closed
Closed

Description

@judahrand

This could be another interesting one as the API can return Arrow formatted data. Perhaps implemented in Go as I believe that's the 1st class SDK?

Activity

  1. lidavidm commented on Nov 10, 2022

    @lidavidm
    Member

    BigQuery Storage sends Arrow over gRPC so it could be done natively for all of C++, Go, and Java. It would be interesting. Though, BQS can't evaluate SQL. So we might want to add the 'inverse' of the ADBC ingest API, for scanning a table without issuing an explicit query (or, specifying that drivers can translate a Substrait read request to such a scan).

    I'm less familiar with the 'standard' BigQuery API. The REST API gives row-oriented JSON which isn't as great.

  2. judahrand commented on Nov 10, 2022

    @judahrand
    ContributorAuthor
  3. lidavidm commented on Nov 15, 2022

    @lidavidm
    Member

    (Sorry for the delay.) Go might be interesting just to prove it out quickly. It may also be interesting to see Go implement the C interface and build an embeddable shared/static library to reduce the maintenance costs. (Right now Go can bind to the C interface, but not yet the other way.)

  4. paleolimbot commented on Nov 24, 2022

    @paleolimbot
    Member

    Obviously the Arrow interface is preferable, but I thought I'd post the C++ that the bigrquery R package uses to parse the JSON since the output data structure is pretty similar and I happen to know where it lives: https://github.com/r-dbi/bigrquery/blob/main/src/BqField.cpp

  5. lidavidm commented on Nov 25, 2022

    @lidavidm
    Member

    Absolutely, but the Arrow interface only applies to (effectively) full table scans with some filters ("BigQuery Storage" != "BigQuery"), so we will need to parse one of the alternative outputs for general queries. Thanks for the reference though!

  6. judahrand commented on Jan 5, 2023

    @judahrand
    ContributorAuthor

    Absolutely, but the Arrow interface only applies to (effectively) full table scans with some filters ("BigQuery Storage" != "BigQuery"), so we will need to parse one of the alternative outputs for general queries. Thanks for the reference though!

    The Python BigQuery SDK uses a trick to push any query into a table and then use BigQuery Storage API to fetch the result. We could use that here too in order to simplify things.

  7. lidavidm commented on Jan 5, 2023

    @lidavidm
    Member

    Ah, interesting. That would be great, then. Thanks for pointing that out.

    I assume that would have cost/pricing implications though, and requires you to materialize the result before reading it?

  8. judahrand commented on Jan 5, 2023

    @judahrand
    ContributorAuthor

    This works because of this:
    image
    https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryJob

    BigQuery just 'handles' it in the backend through the caching mechanism. Effectively, you run the query twice; once with the BigQuery API and once with the BigQuery Storage API but the second time it hits the cache. So I was a bit wrong in the Python manually pushing it into a table - it doesn't. So this shouldn't have cost implications.

  9. judahrand commented on Jan 5, 2023

    @judahrand
    ContributorAuthor
  10. lidavidm commented on Jan 5, 2023

    @lidavidm
    Member

    Oops, clearly I don't understand BigQuery well enough. Thanks (again) for digging into this!

  11. judahrand commented on Jan 6, 2023

    @judahrand
    ContributorAuthor

    Another useful source of inspiration - the Go SDK is in the process of implementing the same fast path as the Python SDK: googleapis/google-cloud-go#6822

    To make the Go implementation straight forward interfaces on top of the changes made here would be made to add a method which is analogous to Python's RowIterator.to_arrow_iterable. That doesn't seem like a stretch, however.

  12. zeroshade commented on Jan 7, 2023

    @zeroshade
    Member

    A nice aspect is that the Go bigquery quickstart example ( https://github.com/GoogleCloudPlatform/golang-samples/blob/main/bigquery/bigquery_storage_quickstart/main.go) actually uses the latest released version of arrow (as opposed to snowflake which vendored a 2 year old version of Go Arrow right into their module)

  13. josevalim commented on Mar 31, 2024

    @josevalim

    I believe the Go client now exposes the Arrow iterator and data: googleapis/google-cloud-go#8506 (which is likely using the RPC API to read the data).

  14. lidavidm commented on Sep 5, 2024

    @lidavidm
    Member

    This was included in the last release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions