【发布时间】:2016-10-12 17:05:23
【问题描述】:
我正在尝试使用应用程序脚本将 Cloud Storage 中的简单 cvs 文件加载到 BigQuery 表中。我已经创建了表并希望将文件附加到表中的现有数据中。当我运行脚本时,我收到以下错误消息“mediaData 参数仅支持 Blob 类型的上传”。我不确定如何在这方面取得进展,并且在寻找答案时遇到了障碍。这是我正在使用的代码 sn-p:
function loadCloudStorageFileToBigQuery(source, datasetId, tableId, schema) {
try{
var tableReference = BigQuery.newTableReference();
tableReference.setProjectId(MY_PROJECT);
tableReference.setDatasetId(datasetId);
tableReference.setTableId(tableId);
var load = BigQuery.newJobConfigurationLoad();
load.setDestinationTable(tableReference);
load.setSourceUris([source]);
load.setSourceFormat('CSV');
load.setSchema(schema);
load.setMaxBadRecords(0);
load.setWriteDisposition('WRITE_TRUNCATE');
var configuration = BigQuery.newJobConfiguration();
configuration.setLoad(load);
var newJob = BigQuery.newJob();
newJob.setConfiguration(configuration);
var job = BigQuery.Jobs.insert(newJob, null, {projectId:MY_PROJECT});
}catch(err){
Logger.log('Table upload error: %s', err);
}
}
任何建议或帮助将不胜感激。
【问题讨论】:
标签: google-apps-script google-bigquery google-cloud-storage