如何使用 App 脚本运行 google big query 并将其保存为新表以供我们重用? [英] How to use App script to run a google big query and save it as a new table which can we reused?

查看:33
本文介绍了如何使用 App 脚本运行 google big query 并将其保存为新表以供我们重用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用应用脚本运行谷歌大查询并将结果保存在谷歌大查询相同项目文件夹中的新表中

How to use app script to run a google big query and save the results in a new table in the same project folder on google big query

推荐答案

它看起来像这样:

function saveQueryToTable() {
  var projectId = 'your project';
  var datasetId = 'your dataset';
  var tableId = 'your table';
  var job = {
    configuration: {
      query: {
        query: 'SELECT TOP(word, 300) AS word, COUNT(*) AS word_count' +
               'FROM publicdata:samples.shakespeare' +
               'WHERE LENGTH(word) > 10;',
        destinationTable: {
          projectId: projectId,
          datasetId: datasetId,
          tableId: tableId
        }
      }
    }
  };

  var queryResults = BigQuery.Jobs.insert(job, projectId);
  Logger.log(queryResults.status);
}

更多示例此处.

这篇关于如何使用 App 脚本运行 google big query 并将其保存为新表以供我们重用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆