dongzeao5047 2017-02-22 10:37
浏览 84
已采纳

从Google BigQuery提取结果到云存储golang

I am using the following GoLang package: https://godoc.org/cloud.google.com/go/bigquery

My app runs in Google App Engine

If I have understood the documentation correctly it should be possible to extract the result of a job/query to Google Cloud Storage using a job. I don't think the documentation is very clear and was wondering if anyone has an example code or other help.

TL:DR

  1. How do I get access to the temporary table when using Go Lang instead of command line.

  2. How do I extract the result of my Bigquery to GCS

** EDIT **

Solution i used

I created a temporary table and set it as the Dst (Destination) for the Query result and created an export job with it.

dataset_result.Table(table_name).Create(ctx, bigquery.TableExpiration(time.Now().Add(1*time.Hour)))

Update 2018:

https://github.com/GoogleCloudPlatform/google-cloud-go/issues/547

To get the table name:

q := client.Query(...)
job, err := q.Run(ctx)
// handle err
config, err := job.Config()
// handle err
tempTable := config.(*QueryConfig).Dst
  • 写回答

1条回答 默认 最新

  • douhao9203 2017-02-22 11:46
    关注

    How do I extract the result of my BigQuery to GCS

    You cannot directly write the results of a query to GCS. You first need to run the query, save the results to a permanent table, and then kick off an export job to GCS.

    https://cloud.google.com/bigquery/docs/exporting-data

    How do I get access to the temporary table when using Go Lang instead of command line.

    You call use the jobs API, or look in the query history if using the web UI. See here and here.

    https://cloud.google.com/bigquery/querying-data#temporary_and_permanent_tables

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题