我正在尝试使用 node.js API 从谷歌云函数创建一个外部表。该函数将从 GCS 存储桶更改触发。我可以创建本机表,但不能创建外部表。在用于在此处导入的 node.js api 中,configuration.load 元数据没有将其指定为外部表的设置。这是我到目前为止创建本机表的代码。我的问题是“如何使用 Node.js Api 为 GCS 存储桶创建外部表”
const projectId = "N"
const bigquery = BigQuery({
projectId: projectId
});
const storage = Storage({
projectId: projectId
});
const dataset = bigquery.dataset("dataset");
const table = dataset.table("test_data");
const bucket = storage.bucket("my-bucket");
const file = bucket.file("2017/03/02/*");
let job;
// Imports data from a GCS file into a table
return table.import(file,{"sourceFormat":"AVRO"})
.then((results) => {
job = results[0];
console.log(`Job ${job.id} started.`);
return job.promise();
})
.then((results) => {
console.log(`Job ${job.id} completed.`);
return results;
});