Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Retrieve data from BigQuery
* @param {string} projectId The ID of the GCP project the dataset/table is located
* @param {string} datasetId The ID of the parent dataset
* @param {string} tableId The ID of the table to get data from
* @returns {Promise<void>}
const getData = async (projectId, datasetId, tableId) => {
const query = `
SELECT * from \`${projectId}.${datasetId}.${tableId}\`
const options = {
query: query,
// Location must match that of the dataset(s) referenced in the query.
// Run the query as a job
const [job] = await bigquery.createQueryJob(options);
console.log(`Job '${}' started.\n`);
// Wait for the query to finish
const [rows] = await job.getQueryResults();
// Print the results
console.log('Resulted Rows:');
rows.forEach(row => console.log(row));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment