【发布时间】:2021-12-13 13:55:59
【问题描述】:
代码基本上是 bigquery API 文档的精确副本:
const { BigQuery } = require("@google-cloud/bigquery");
const bigquery = new BigQuery();
const dataset = bigquery.dataset("firebase_test_data");
const table = dataset.table("flattened_data");
const fs = require("fs");
fs.createReadStream("./data.json")
.pipe(table.createWriteStream("json"))
.on("job", (job) => {
// `job` is a Job object that can be used to check the status of the
// request.
console.log(job);
})
.on("complete", (job) => {
// The job has completed successfully.
});
引发的错误如下:作业或表上未指定架构。
不知道为什么会这样,因为它几乎是文档代码的精确副本!我也尝试过遵循 fs.createWriteStream({sourceFormat: "json"}) 等不同格式 - 导致相同的错误。
【问题讨论】:
-
您的 data.json 文件是否包含表中存在的所有列?
-
表完全是空的,我在尝试之前刚刚创建了它。我应该先将列添加到表中吗:O?
-
对不起,我想我误解了你在这里想要做什么。您是否尝试从 ./data.json 文件中插入数据?
-
如果您觉得我的回答对您的问题有帮助,请考虑接受并按Stack Overflow guidelines 点赞,帮助更多 Stack 贡献者进行研究。
标签: node.js google-cloud-platform google-bigquery fs