Skip to content

[Q] BigQuery: example using standard SQL #6671

Closed

Description

@jgsogo

Hi! I'm starting to use these C++ libraries to connect to different GCP services. I'm really interested in BigQuery.

I'm looking for a C++ example using standard SQL syntax, like the ones here for other languages: https://cloud.google.com/bigquery/docs/samples/bigquery-query. I assume it is the best way to consume less data. I've seen something related to this in bigquery/v2 protos, but I don't know how to use it with a BigQuery client.

Is it possible to do something similar using google-cloud-cpp? Is there any other approach I can use?

Thanks in advance!

Activity

  1. added
    type: question
    on Jun 2, 2021
  2. devjgm commented on Jun 2, 2021

    @devjgm
    Contributor

    Hi! I'm starting to use these C++ libraries to connect to different GCP services.

    Great! I hope we can help.

    I'm really interested in BigQuery.

    I'm looking for a C++ example using standard SQL syntax, like the ones here for other languages: https://cloud.google.com/bigquery/docs/samples/bigquery-query. I assume it is the best way to consume less data.

    Can you please clarify what you mean by "consume less data"?

    I've seen something related to this in bigquery/v2 protos, but I don't know how to use it with a BigQuery client.

    Those protos appear to be an incomplete representation of the interface to query BigQuery. It looks like it only exposes the ModelService, so I don't think they will be enough for what you need.

    Is it possible to do something similar using google-cloud-cpp? Is there any other approach I can use?

    We do have a C++ client library for reading bulk data form BigQuery's storage interface (code). This library should be Generally Available (GA) soon. But this library does not offer an SQL querying interface.

    To query using standard SQL syntax, I think the REST interface is your only option at this point. We do not have a C++ client library for this interface at the moment.

  3. jgsogo commented on Jun 2, 2021

    @jgsogo
    Author

    Thanks for the answer, I'll have a look at the REST interface while I wait for that SQL client 😃


    Can you please clarify what you mean by "consume less data"?

    AFAIK, BigQuery is charged for the amount of data processed in the queries. I suppose that reading bulk all the table is more expensive than executing the query and retrieving just some data (these are big tables, in the order of Gigabytes) and probably it is faster than transferring all that information and filtering on the client-side. But all of this is just my guess, probably pricing for storage interface is lower than SQL interface... but still, the data transfer and time can be an issue.

  4. locked and limited conversation to collaborators on Jun 18, 2021
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

    type: question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions