繁体   English   中英

Google Bigquery的Apps脚本未知错误

[英]Apps Script to Google Bigquery unknown error

CSThis应该读入a,然后将其写入bigquery。 但是,当它运行时,不会写入任何内容,也不会记录任何错误。 我读到我需要编写一个csv,然后将其转换为八位位组流。 我不确定这是否与Google bigquery兼容。 我还尝试删除了setSourceUris,但仍然没有任何错误显示。

function test(){
try{
 var tableReference = BigQuery.newTableReference();
 tableReference.setProjectId(PROJECT_ID);
 tableReference.setDatasetId(datasetId);
 tableReference.setTableId(tableId);
 var schema = "CUSTOMER:string, CLASSNUM:integer, CLASSDESC:string, CSR:string, CSR2:string,     INSURANCE:string, REFERRALGENERAL:string, REFERRALSPECIFIC:string, NOTES:string, INMIN:integer, INHR:integer, OUTMIN:integer, OUTHR:integer, WAITMIN:integer, WAITHR:integer, DATETIMESTAMP:float, DATEYR:integer,DATEMONTH:integer, DATEDAY:integer";
 var load = BigQuery.newJobConfigurationLoad();
 load.setDestinationTable(tableReference);
 load.setSourceUris(URIs);
 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 loadr = DriveApp.getFilesByName("test.csv");
 var x = loadr.next().getBlob();
 Logger.log(x.getDataAsString());

 var d = DriveApp.getFilesByName("test.csv");
 var id = d.next().getId();
 Logger.log(id);
 var data = DocsList.getFileById(id).getBlob().getDataAsString();
 var mediaData = Utilities.newBlob(data, 'application/octet-stream');

 BigQuery.Jobs.insert(newJob, PROJECT_ID, mediaData) 
} 
catch(error){Logger.log("A" + error.message);} 
}

Apps脚本文档包含一些示例代码,这些示例代码显示了如何将CSV加载到bigquery中: https : //developers.google.com/apps-script/advanced/bigquery#load_csv_data

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM