I make query to Google BigQuery, and it works in console, but fail when I try the same in google app script here is the code:
in console runs normal:
SELECT title FROM [bigquery-public-data:samples.wikipedia] where title contains 'olimpic' LIMIT 100
in app script it runs with error:
Encountered " "-" "- "" at line 1, column 27. Was expecting: EOF
function runQuery() {
var projectId = 'cool-reality-177704';
var request = {
query: 'SELECT title FROM bigquery-public-data:samples.wikipedia where title contains "olimpic" LIMIT 100'
};
var queryResults = BigQuery.Jobs.query(request, projectId);
var jobId = queryResults.jobReference.jobId;
Logger.log(queryResults)
}
What I do wrong?
You're missing the square brackets around the
project:dataset.table
name. It should be:'SELECT title FROM [bigquery-public-data:samples.wikipedia] where title contains "olimpic" LIMIT 100'
Note: try to avoid using legacy SQL. I'd do this instead (use standard SQL):