Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 如何设置从Google云存储获取数据的Google应用程序脚本中自动检测的表的模式?_Google Apps Script_Google Bigquery_Google Cloud Storage - Fatal编程技术网

Google apps script 如何设置从Google云存储获取数据的Google应用程序脚本中自动检测的表的模式?

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="

我有一个Google应用程序脚本,通过从Google云存储获取更新的数据,自动更新Bigquery中的表

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);”

更多详情: