Skip to content

Instantly share code, notes, and snippets.

@ensargunesdogdu
Created August 9, 2021 11:10
Show Gist options
  • Save ensargunesdogdu/834765f8fc40e9e49fa244ee03e8dc8a to your computer and use it in GitHub Desktop.
Save ensargunesdogdu/834765f8fc40e9e49fa244ee03e8dc8a to your computer and use it in GitHub Desktop.
// Import the Google Cloud client library using default credentials
const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
async function query() {
const query = "SELECT * FROM \`$TABLE_NAME\` LIMIT 1000";
const options = {
query: query,
// Location must match that of the dataset(s) referenced in the query.
location: 'europe-west4',
};
const [job] = await bigquery.createQueryJob(options);
console.log(`Job ${job.id} started.`);
const [rows] = await job.getQueryResults();
console.log('Rows:');
rows.forEach(row => console.log(row));
}
query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment