Google apps script 如何设置从Google云存储获取数据的Google应用程序脚本中自动检测的表的模式?
我有一个Google应用程序脚本,通过从Google云存储获取更新的数据,自动更新Bigquery中的表Google apps script 如何设置从Google云存储获取数据的Google应用程序脚本中自动检测的表的模式?,google-apps-script,google-bigquery,google-cloud-storage,Google Apps Script,Google Bigquery,Google Cloud Storage,我有一个Google应用程序脚本,通过从Google云存储获取更新的数据,自动更新Bigquery中的表 function loadCloudStorageFileToBigQuery(source,ProjectId, datasetId, tableId, schema) { try{ source="xxxxx"; ProjectId="xxxxxx"; datasetId="xxxxxx"; tableId="
function loadCloudStorageFileToBigQuery(source,ProjectId, datasetId, tableId, schema) {
try{
source="xxxxx";
ProjectId="xxxxxx";
datasetId="xxxxxx";
tableId="xxxxxxx";
schema={"configuration.load.autodetect":'true'};
var tableReference = BigQuery.newTableReference();
tableReference.setProjectId(ProjectId);
tableReference.setDatasetId(datasetId);
tableReference.setTableId(tableId);
var load = BigQuery.newJobConfigurationLoad();
load.setDestinationTable(tableReference);
load.setSourceUris([source]);
load.setSourceFormat('CSV');
load.setMaxBadRecords(0);
load.setWriteDisposition('WRITE_APPEND');
var configuration = BigQuery.newJobConfiguration();
configuration.setLoad(load);
var newJob = BigQuery.newJob();
newJob.setConfiguration(configuration);
var job = BigQuery.Jobs.insert(newJob, ProjectId);
}catch(err){
Logger.log('Table upload error: %s', err);
}
}
脚本似乎工作正常,因为我可以在大查询中看到作业历史记录中的错误。错误表示未定义架构。我想将架构设置为自动检测。有人能建议我在脚本中所做的更改吗?添加“load.setAutodetect(true);”
更多详情:
添加“load.setAutodetect(true);”
更多详情: