【问题标题】:BigQuery API does not return newest table of a datasetBigQuery API 不返回数据集的最新表
【发布时间】:2021-10-19 13:38:22
【问题描述】:

我需要在 BigQuery 数据集中按创建时间查找最新的表。我有一个可以找到最新表的 Google Apps 脚本函数,当数据集中只有几个表时它可以正常工作,但是自从数据集中有更多表(准确地说是 72 个)它只是不断返回相同的“最新”表(例如 tablename_1623468444656),即使我知道存在更新的表。

问题似乎是记录器输出的大小,因为当我记录输出时它说:“记录输出太大。截断输出”。但无论我是否记录输出,它只会返回据称是最新的表(例如 tablename_1623468444656)。

我不知道我需要更改什么以便函数可以再次找到实际的最新表。函数如下所示:

function findNewestTables() {
    const data = BigQuery.Tables.list('Projectname', 'Datasetname');
    let
      maxSoFar = 0,
      id = ""; 

    data.tables.forEach(table => {
      const time = parseInt(table.creationTime);
      if(time > maxSoFar){
        maxSoFar = time; 
        id = table.id;
      }
    });
    const formattedId = id.replace(":", ".");
    // return formattedId;
    console.log(data);
    console.log(formattedId);
};

部分输出看起来像这样,然后突然被切断。

Logging output too large. Truncating output. { totalItems: 72,
  kind: 'bigquery#tableList',
  etag: '7+eK1beNA7CVq0xasdfdsfYw==',
  nextPageToken: 'Team_1627356444573',
  tables: 
   [ { id: 'tablename_1623468444656',
       type: 'TABLE',
       kind: 'bigquery#table',
       creationTime: '1628585864499',
       tableReference: [Object] },
     { tableReference: [Object],
       id: 'tablename_1623554844685',
       kind: 'bigquery#table',
       creationTime: '1628585864503',
       type: 'TABLE' },
     { id: 'tablename_1623641244614',
       type: 'TABLE',
       kind: 'bigquery#table',
       tableReference: [Object],
       creationTime: '1628585864573' },
     { tableReference: [Object],
       kind: 'bigquery#table',
       creationTime: '1628585864714',
       type: 'TABLE',
       id: 'tablename_1623727644545' },
     { tableReference: [Object],
       kind: 'bigquery#table',
       type: 'TABLE',
       creationTime: '1628585865059',
       id: 'tablename_1623814044558' },
     { creationTime: '1628585865037',
       id: 'tablename_1623900444676',
       type:

提前感谢您的任何提示。

【问题讨论】:

    标签: javascript node.js google-bigquery


    【解决方案1】:

    因此,这是您需要分页的情况之一。看到nextPageToken?如果该值不为空/nil,则意味着您可以再次调用 tables.list 并在后续请求中将该令牌作为 pageToken GET 参数传递以获取下一页结果。

    有关 API 的更多详细信息:https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/list

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      • 2021-02-05
      • 2014-11-06
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      相关资源
      最近更新 更多