Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated Apps Script for BigQuery Failing

I keep getting this error

"ReferenceError: "BigQuery" is not defined. (line 19, file "Code")"

when trying to this script in apps script

function saveQueryToTable() {
  var projectId = 'fiery-cabinet-****';
  var datasetId = '11234***1';
  var tableId = 'TEST4';
  var job = {
    configuration: {
      query: {
        query: 'SELECT *' +
               'FROM Test2;',
        destinationTable: {
          projectId: projectId,
          datasetId: datasetId,
          tableId: tableId
        }
      }
    }
  };

  var queryResults = BigQuery.Jobs.insert(job, projectId);
  Logger.log(queryResults.status);
}

Could anyone let me know where I'm going wrong?

Thanks

like image 787
Aaron Harris Avatar asked Mar 23 '17 10:03

Aaron Harris


1 Answers

You need to enable the BigQuery service.

  1. Resources > Advanced Google Services
  2. Enable BigQuery

enter image description here

like image 100
Graham Polley Avatar answered Sep 22 '22 16:09

Graham Polley