How to use the @google-cloud/bigquery function in @google-cloud/bigquery

To help you get started, we’ve selected a few @google-cloud/bigquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bdash-app / bdash / src / lib / DataSourceDefinition / BigQuery.ts View on Github external
async connectionTest(): Promise {
    await bigquery(this.config).query("select 1");
  }
github bdash-app / bdash / src / lib / DataSourceDefinition / BigQuery.ts View on Github external
return new Promise((resolve, reject) => {
      bigquery(this.config).startQuery(query, (err, job) => {
        if (err) return reject(err);

        this._cancel = async () => {
          await job.cancel();
          reject(new Error("Query is canceled"));
        };

        job.getQueryResults((err, rows) => {
          if (err) return reject(err);
          if (rows.length === 0) return resolve({});

          resolve({
            fields: Object.keys(rows[0]),
            rows: rows.map(Object.values)
          });
        });
github bdash-app / bdash / src / lib / DataSourceDefinition / BigQuery.ts View on Github external
async fetchTableSummary({
    schema,
    name
  }: {
    schema: string;
    name: string;
  }): Promise<{ name: string; defs: { fields: string[]; rows: (string | null)[][] }; schema?: string }> {
    const [metadata] = await bigquery(this.config)
      .dataset(schema)
      .table(name)
      .getMetadata();
    const schemaFields = metadata.schema.fields;
    const defs = {
      fields: Object.keys(schemaFields[0]),
      rows: schemaFields.map(Object.values)
    };
    return { schema, name, defs };
  }
github bdash-app / bdash / src / lib / DataSourceDefinition / BigQuery.ts View on Github external
async fetchTables(): Promise<{ name: string; type: string; schema?: string }[]> {
    const [datasets]: [any[]] = await bigquery(this.config).getDatasets();
    const promises = datasets.map>(async dataset => {
      const [tables] = await dataset.getTables();
      return tables.map(table => ({
        schema: dataset.id,
        name: table.id,
        type: table.metadata.type.toLowerCase()
      }));
    });
    const results = await Promise.all(promises);
    return flatten(results);
  }

@google-cloud/bigquery

Google BigQuery Client Library for Node.js

Apache-2.0
Latest version published 3 months ago

Package Health Score

86 / 100
Full package analysis