I am trying to create an external table from a google cloud function using the node.js API. The function will trigger from GCS bucket changes. I can create a native table but not an external table. In the node.js api for import here, the configuration.load metadata does not have a setting to specify this as external table. Here is my code for native table creation till now. My question is "How do I use the Node.js Api to create external table for a GCS bucket"
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;
});