io icon indicating copy to clipboard operation
io copied to clipboard

Read data from BigQuery from a query, not the entire table

Open francisco64 opened this issue 4 years ago • 1 comments

Hi and thanks for your kind help,

In the End to end example for BigQuery TensorFlow reader the method tensorflow_io.bigquery.BigQueryClient.read_session is used to read a table from BigQuery. I don't need just a table but data from a query. Is this possible with the read_session method or I need another method, tool, library?

Thank you again!

francisco64 avatar Sep 19 '21 00:09 francisco64

BigQuery TensorFlow reader can only read from the table, but you have an option to select which columns you want to read. It is limited to the functionality that BigQuery storage API provides, see https://cloud.google.com/bigquery/docs/reference/storage

As a workaround you can materialize your queries in BQ. Alternatively you can use google-cloud-bigquery python library https://googleapis.dev/python/bigquery/latest/reference.html but it is going to be way slower compared to TF BQ reader.

vlasenkoalexey avatar Nov 18 '21 16:11 vlasenkoalexey