BigQuery Node.js api创build外部表

我正尝试使用node.js API从Google云端函数创build外部表格。 该function将从GCS桶更改中触发。 我可以创build一个本地表,但不能创build一个外部表。 在这里用于导入的node.js api中,configuration.load元数据没有设置来将其指定为外部表。 这里是我的代码本地表创build到现在。 我的问题是“如何使用Node.js Api为GCS存储桶创build外部表”

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; }); 

在阅读了文档之后,我find了解决scheme。 联合表通过加载/导入它们不起作用。 他们只是用externalConfig设置。 所以这个代码为我工作

 const dataset = bigquery.dataset("dataset"); var options = { "externalDataConfiguration": { "sourceUris": ["gs://my-bucket/2017/03/20/*"], "sourceFormat": "AVRO", "maxBadRecords": 0, "autodetect": true } } dataset.createTable("test_data_20170320",options, function(err, table, apiResponse){ console.log(err) console.log(table) console.log(apiResponse) })