Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
How i can get bigquery table data in google script?

I want to bigquery table data using app script ,I am using this code but i am getting job id, i dont job id i want table data please help me this.

    function runQuery() {
     DriveApp.getRootFolder();
    var projectId = 'imran-338706';
   var request = {
   query: 'SELECT network_affiliate_name FROM `imran-338706.imranabc.bhk` LIMIT 10',
 useLegacySql: false
 }
var queryResults = BigQuery.Jobs.query(request, projectId);
   var jobId = queryResults.jobReference.jobId;
console.log(queryResults)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I verified using the following code for queries returning small amount of data :

function runQuery() {
DriveApp.getRootFolder();
var projectId = ProjectID;
var request = {
 query: 'SELECT * from `bigquery-public-data.austin_311.311_service_requests` limit 2',
 useLegacySql: false
}
var queryResults = BigQuery.Jobs.query(request, projectId);
var jobId = queryResults.jobReference.jobId;
var rows = queryResults.rows;
 
var header = "";
for (var i = 0; i < queryResults.schema.fields.length; i++){
header+= " " + queryResults.schema.fields[i].name;
}
console.log(header)
 
 
var data = new Array(rows.length);
var string = ""
for (var i = 0; i < rows.length; i++) {
 var cols = rows[i].f;
 data[i] = new Array(cols.length);
 for (var j = 0; j < cols.length; j++) {
   data[i][j]= cols[j].v;
   string+= " "+ data[i][j]
 
 }
 console.log(string);
 }
}

It gave the schema and row contents: enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!