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 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)