我不知道这是否是寻求帮助的正确地方,但也许有人可以给我一些提示:
我正试图将我的数据从我的项目(在本地模拟器套件中运行(推送到大查询中。因此,我从"复制了扩展代码https://github.com/firebase/extensions/tree/master/firestore-bigquery-export'
我添加了一个云函数来导出我的成员集合,当我在该集合中创建新文档时,也会创建大查询数据集和表。但我在本地控制台中收到以下错误消息:
"将数据镜像到BigQuery ApiError时出错:无效的表名:未定义.firestore_members.members_raw_changelog">
有人能给我一个提示吗?是";未定义的";属性projectId?为什么没有设定好呢?如果我做
console.log('PROJECT-ID:', await this.bq.getProjectId());
在初始化功能中,它显示正确。。。
这是由于函数依赖项中的代码出现问题。代码是在snapshot.ts中编写的,它试图使用表和数据集创建一个视图。与此同时,它还试图从env中选择项目id。process.env.PROJECT_ID.我的建议是将他的设置为一个属性。这是代码:
return format(
` -- Retrieves the latest document change events for all live documents.
-- timestamp: The Firestore timestamp at which the event took place.
-- operation: One of INSERT, UPDATE, DELETE, IMPORT.
-- event_id: The id of the event that triggered the cloud function mirrored the event.
-- data: A raw JSON payload of the current state of the document.
-- document_id: The document id as defined in the Firestore database
SELECT
document_name,
document_id${groupByColumns.length > 0 ? "," : ""}
${groupByColumns.join(",")}
FROM (
SELECT
document_name,
document_id,
${groupByColumns
.map(
(columnName) =>
`FIRST_VALUE(${columnName})
OVER(PARTITION BY document_name ORDER BY ${timestampColumnName} DESC)
AS ${columnName}`,
)
.join(",")}${groupByColumns.length > 0 ? "," : ""}
FIRST_VALUE(operation)
OVER(PARTITION BY document_name ORDER BY ${timestampColumnName} DESC) = "DELETE"
AS is_deleted
FROM `${process.env.PROJECT_ID}.${datasetId}.${tableName}`
ORDER BY document_name, ${timestampColumnName} DESC
)
WHERE NOT is_deleted
GROUP BY document_name, document_id${
groupByColumns.length > 0 ? ", " : ""
}${groupByColumns.join(","(}`,