Karl Lin
Karl Lin

Reputation: 317

Write BigQuery query result directly to GCS - is it possible?

I tried the bq command line tool, but it there seems to be no way to write the results directly to GCS. The only way I can see is working is:

  1. query -> table -> export
  2. query -> console -> local CSV file -> upload to GCS

I'm looking for a way to directly write the results to GCS.

Upvotes: 2

Views: 1557

Answers (1)

Graham Polley
Graham Polley

Reputation: 14791

You cannot write your query results directly to GCS. The easiest way, as you've already pointed out, is to:

  1. Write your query results to an output table
  2. Export your table to GCS

You easily do this in the web UI.

You could also write a Dataflow pipeline that reads from BigQuery using BigQuery.IO.Read.fromQuery(<your_query>), and write the results directly to GCS.

Upvotes: 2

Related Questions