简体   繁体   English

尝试连接到 nodejs 中的 BigQuery 时出现问题

[英]Issue while trying to connect to BigQuery in nodejs

node version: v18.12.1 @google-cloud/bigquery version: v6.0.3节点版本:v18.12.1 @google-cloud/bigquery 版本:v6.0.3

I am using a service account to to connect to bigQuery, then trying to run a simple query.我正在使用服务帐户连接到 bigQuery,然后尝试运行一个简单的查询。 Query is working fine on google console but for some reason I am facing issues while running it with nodejs查询在谷歌控制台上运行良好但由于某种原因我在使用 nodejs 运行它时遇到问题

const authFile = require("./enums/authFile.json");
const { BigQuery } = require("@google-cloud/bigquery");

const queryDb = new BigQuery({
    keyFilename: authFile,
    projectId: "projectId"
  });

  const result = await queryDb.createDataset("new_1datasetId", { location: "US" });

I am getting this error for every kind of query I try to run.我尝试运行的每种查询都会收到此错误。 Even when I try to create a queryJob with即使当我尝试创建一个 queryJob 时

const [job] = await bigquery.createQueryJob(options);
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
    at new NodeError (node:internal/errors:393:5)
    at validateString (node:internal/validators:163:11)
    at Object.resolve (node:path:1098:7)
    at GoogleAuth.getClient (/usr/src/app/node_modules/google-auth-library/build/src/auth/googleauth.js:633:39)
    at GoogleAuth.authorizeRequest (/usr/src/app/node_modules/google-auth-library/build/src/auth/googleauth.js:679:35)
    at authorizeRequest (/usr/src/app/node_modules/@google-cloud/common/build/src/util.js:439:47)
    at prepareRequest (/usr/src/app/node_modules/@google-cloud/common/build/src/util.js:444:25)
    at BigQuery.makeAuthenticatedRequest (/usr/src/app/node_modules/@google-cloud/common/build/src/util.js:455:13)
    at BigQuery.request_ (/usr/src/app/node_modules/@google-cloud/common/build/src/service.js:148:18)
    at BigQuery.request (/usr/src/app/node_modules/@google-cloud/common/build/src/service.js:159:36)
    at BigQuery.createDataset (/usr/src/app/node_modules/@google-cloud/bigquery/build/src/bigquery.js:902:14)
    at /usr/src/app/node_modules/@google-cloud/promisify/build/src/index.js:57:28
    at new Promise (<anonymous>)
    at BigQuery.wrapper (/usr/src/app/node_modules/@google-cloud/promisify/build/src/index.js:42:16)
    at checkAlert (/usr/src/app/src/helpers/echo.js:131:34)
    at /usr/src/app/src/helpers/echo.js:118:9 {
  code: 'ERR_INVALID_ARG_TYPE'

Your authFile is a module.您的authFile是一个模块。 The constructor expects a path to the file itself .构造函数需要一个文件本身的路径

const queryDb = new BigQuery({
  keyFilename: "./enums/authFile.json",
  projectId: "projectId"
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试从 BigQuery 获取数据时 Vertex AI Pipeline 失败 - Vertex AI Pipeline is failing while trying to get data from BigQuery 在 Oracle 到 BigQuery 之间创建 DataFusion 复制时缺少功能问题 - Missing Feature issue while creating DataFusion Replication between Oracle to BigQuery “AttributeError: 'GoogleBaseHook' object 没有属性 'get_records'” 尝试为 BigQuery 运行自定义 SqlSensor 时出错 - "AttributeError: 'GoogleBaseHook' object has no attribute 'get_records'" Error while trying to run Custom SqlSensor for BigQuery 尝试使用 terraform 使用 google_bigquery_data_transfer_config 复制数据时出错 - getting error while trying to copy data using google_bigquery_data_transfer_config using terraform Bigquery 日期问题 - Bigquery Date Issue 在 bigquery 中拆分字符串的问题 - Issue with splitting string in bigquery Automl SDK 代码,文件位置来自 bigquery,但在预测时有问题 - Automl SDK code with file location from bigquery but having issue while predicting 使用服务帐户凭据连接到 BigQuery? - Connect to BigQuery with Service Account Credentials? 将 Bigquery function 与云功能连接起来 - Connect a Bigquery function with Cloud functions 是否有任何 VSCode 扩展可以连接到 BigQuery? - Are there any VSCode extensions that will connect to BigQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM