title: How to pass an array into a query string in Google App Script for a Google Spreadsheet
body: <p>I have a script that will take a query in the form of a string variable (named <code>sql</code>) and pull data from BigQuery to a Google Spreadsheet.
  Something like below:</p>
  
  <pre><code>var sql = "SELECT field1, field2 FROM table";
  var queryResults;
  
  try {
  var queryRequest = BigQuery.newQueryRequest();
  queryRequest.setQuery(sql).setTimeoutMs(100000).setUseLegacySql(false);
  queryResults = BigQuery.Jobs.query(queryRequest, projectNumber);
  }
  </code></pre>
  
  <p>Now, I want to create an array variable and pass it to the <code>sql</code> query string. When I pass the array as a variable like below, it didn't work: Google SpreadSheet gave me an error: </p>
  
  <blockquote>
    <p>GoogleJsonResponseException: Unrecognized name: becca at [1:1088]<br>
    ("becca" is the first value of my array)</p>
  </blockquote>
  
  <pre><code>var array = ['a','b','c']
  var sql = "SELECT field1 FROM UNNEST("+array+") AS field1";
  </code></pre>
  
  <p>It only worked when I manually hard code the array of strings, like below:</p>
  
  <pre><code>var sql = "SELECT field1 FROM UNNEST(['a','b','c']) AS field1";
  </code></pre>
  
  <p>However my array is supposed to be dynamic so manually hard coding it is not an option. How do I pass it as a variable then?</p>