Skip to main content

Google BigQuery

Google BigQuery is an enterprise data warehouse that allows you to store and query massive datasets at high speed using Google's infrastructure

Google BigQuery snippets available in YepCode editor#


The title is the triggering text for YepCode to autocomplete the script


New integration from credential
const googleBigQueryClient = yepcode.integration.googleBigQuery("credential-slug");
New integration from plain authentication data
const { BigQuery } = require("@google-cloud/bigquery");
const googleBigQueryCredentials = {  projectId: "YepCode",  credentials: {    type: "service_account",    project_id: "yepcode",    private_key_id: "XXXXX",    private_key: \`-----BEGIN PRIVATE KEY-----\nx\n-----END PRIVATE KEY-----\`,    client_email: "",    client_id: "1234567890",    auth_uri: "",    token_uri: "",    auth_provider_x509_cert_url: "",    client_x509_cert_url: "",  }};
const googleBigQueryClient = new BigQuery(googleBigQueryCredentials);

Create a dataset#

Create a dataset
async function createDataset() {  // Specify the geographic location where the dataset should reside  const options = {    location: "dataset-location",  };
  const [dataset] = await googleBigQueryClient.createDataset("dataset-id", options);  console.log(`Dataset ${} created.`);}

Delete a dataset#

Delete a dataset
async function deleteDataset() {  // Create a reference to the existing dataset  const dataset = googleBigQueryClient.dataset("dataset-id");
  await dataset.delete({force: true});  console.log(`Dataset ${} deleted.`);}

Query to a dataset#

Query to a dataset
async function query() {  const query = "your-SQL-query";
  // For all options, see  const options = {    query: query,    // Location must match that of the dataset(s) referenced in the query.    location: "dataset-location",  };
  // Run the query as a job  const [job] = await googleBigQueryClient.createQueryJob(options);  console.log(`Job ${} started.`);
  // Wait for the query to finish  const [rows] = await job.getQueryResults();
  // Use the result  // Your code here}