【发布时间】: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