【问题标题】:Firebase Local Emulator and Big-Query: Invalid Table NameFirebase 本地模拟器和大查询:无效的表名
【发布时间】:2021-11-09 14:31:04
【问题描述】:

我不知道这是否是寻求帮助的正确地方 - 但也许有人可以给我一些提示:

我正在尝试将我的数据从我的项目(在本地模拟器套件中运行)推送到大查询。因此我从'https://github.com/firebase/extensions/tree/master/firestore-bigquery-export'复制了扩展代码

我添加了一个云功能来导出我的成员集合,当我在该集合中创建一个新文档时,也会创建大查询数据集和表。 但我在本地控制台中收到以下错误消息:

“将数据镜像到 BigQuery ApiError 时出错:表名无效: undefined.firestore_members.members_raw_changelog"

谁能给我一个提示?是projectId的“未定义”属性吗?为什么没有设置?如果我做一个

console.log('PROJECT-ID:', await this.bq.getProjectId());

在初始化函数中它正确显示...

【问题讨论】:

    标签: firebase google-cloud-firestore google-bigquery firebase-tools


    【解决方案1】:

    这是由于函数依赖项中的代码存在问题。代码写在 snapshot.ts 中,它尝试使用 table 和 datasetid 创建视图。与此同时,它还试图从 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(",")}`,

    【讨论】:

      猜你喜欢
      • 2021-05-29
      • 1970-01-01
      • 2017-12-21
      • 1970-01-01
      • 2020-10-22
      • 1970-01-01
      • 2021-12-16
      • 2020-02-04
      • 1970-01-01
      相关资源
      最近更新 更多