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

143
Views
How can I get a BigQuery query as an array in Google App Script?

I am pretty new to programming in general and completely new to using BigQuery, apologies if this is a stupid question.

I am working on a project where users are supposed to fill out a Google Form, which then runs a google app script to send an email with some data from within the form. One of the fields from the form has to be validated from within BigQuery if it is unique or not out of 8 million rows, if it is not unique, the user gets an email back saying they already submitted this.

The place that I am stuck is getting the BigQuery query as an array in Google App script, which then should be validated, either with an index or .includes().

The closest I got to what I want is getting the bigquery Result, but I am not sure how to turn it into a usable array.

  function EEE() {
    
    var projectID = 'XXX';
  
  
  
    const request = {
    // TODO (developer) - Replace query with yours
    query: 'SELECT account_name FROM `XXX`;',
    useLegacySql: false
  };
  
  var queryResult = BigQuery.Jobs.query(request,projectID);
  
  var jobID = queryResult.jobReference.jobID;
  
  
  // Check on status of the Query Job.
  let sleepTimeMs = 500;
  while (!queryResult.jobComplete) {
    Utilities.sleep(sleepTimeMs);
    sleepTimeMs *= 2;
    queryResult = BigQuery.Jobs.getQueryResults(projectID, jobID);
  }
  
  
  Logger.log(queryResult);
  
}

This gave me the following input:

[22-03-18 02:26:25:065 PDT] Logging output too large. Truncating output. {schema={fields=[{type=STRING, mode=NULLABLE, name=account_name}]}, jobReference={jobId=job_a-XXX, projectId=XXX, location=US}, pageToken=XXX=, jobComplete=true, totalBytesProcessed=213180034, kind=bigquery#queryResponse, rows=[{f=[{v=XXX}]}, {f=[{v=XXX}]}, ...............

I am trying to get the bigQuery output as an array, to be validated if it is unique or not with another variable from the script. I also need it as variable1,variable2,variable 3 rather than with all the wrappers around it. What would be the best way to go about this?

Thank you in advance for the assistance!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Logger has a limited size of what it can display in the popup window and that's why it truncates the results. Your query result is too big.

Try returning it in chunks with a query like:

SELECT account_name FROM XXX order by account_name limit <a> offset <b>;

then you can vary the values of limit and offset to return the different chunks.

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!