我相信这是正确设置作业配置,但我无法弄清楚如何让作业运行。有没有人成功使用 Apps 脚本将表加载到 BigQuery?
function testLoad(){
var fields = [
{'name': 'FirstName', 'type':'STRING'},
{'name': 'LastName', 'type':'STRING'}
];
var schema = BigQuery.newTableSchema()
schema.setFields(fields)
var tableReference = BigQuery.newTableReference()
tableReference.setProjectId(PROJECT_ID);
tableReference.setDatasetId('Test_Dataset');
tableReference.setTableId('TestTable1');
var load = BigQuery.newJobConfigurationLoad();
load.setDestinationTable(tableReference);
load.setSkipLeadingRows(1);
load.setSourceUris([SOURCE]);
load.setSourceFormat('CSV');
load.setSchema(schema)
var configuration = BigQuery.newJobConfiguration();
configuration.setLoad(load);
var newJob = BigQuery.newJob();
newJob.setConfiguration(configuration);
var insert = BigQuery.Jobs.insert(newJob)
Logger.log(insert.getId());
}