Wait for BigQuery queries to complete

Hi, I have been trying for hours to write a JS query that triggers a BiqQuery sql query written in retool, then triggers another, then triggers a retool query, asynchronously. I can't work out how to await the Big Query query completion -- all the advice around here seems to be based around JS queries, where one can return a Promise and the await that. But a BigQuery query cannot be made to return a promise. I don't know what to do.

Hey @prettyman!

Calling query.trigger() should always return a promise regardless of the query type, it resolves to whatever would populate the query's data property. So you can do:

const bqData = await bigQuery.trigger();
const restData = await restQuery.trigger();
const jsData = await jsQuery.trigger();

Note that the JS queries are also async functions by default!