googleapis / nodejs-bigquery

Node.js client for Google Cloud BigQuery: A fast, economical and fully-managed enterprise data warehouse for large-scale data analytics.

Home Page:https://cloud.google.com/bigquery/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setting GOOGLE_APPLICATION_CREDENTIALS break bigquery

flapili opened this issue · comments

Hi,

settings GOOGLE_APPLICATION_CREDENTIALS totally break bigquery

Environment details

  • OS: macos somona
  • Node.js version: 18.18.2 via nvm
  • npm version: pnpm8.10.2
  • @google-cloud/bigquery version: 7.3.0

Steps to reproduce

import process from "node:process";
import { BigQuery } from "@google-cloud/bigquery"

const path = "./project-id-123456789.json"

async function listDatasets(client) {
    const [datasets] = await client.getDatasets();
    console.log(`Datasets:\n${datasets.map((dataset) => ` - ${dataset.id}`).join("\n")}\n`);
}
// work, return the datasets
await listDatasets(new BigQuery({
    projectId: "foobar",
    keyFile: path,
}))

// doesn't work, but doesn't throw any error, just return empty list
process.env.GOOGLE_APPLICATION_CREDENTIALS = path
await listDatasets(new BigQuery())

// doesn't work anymore 
await listDatasets(new BigQuery({
    projectId: "foobar",
    keyFile: path,
}))