Pubsub 到 BigQuery 订阅:架构修订导致 BigQuery 中出现空值

问题描述 投票:0回答:1

我面临着 pubsub 架构演变的问题,当我添加新字段时,它们的值最终在 BigQuery 中为空。我的项目结构如下。

PubSub 架构

{
  "namespace": "com.value.model",
  "name": "ValuePoint",
  "type" : "record",
  "fields" : [
    {
      "name" : "application_id",
      "type" : "string"
    },
    {
      "name" : "user_id",
      "type" : "string"
    }
  ]
}

PubSub 到 BQ 订阅

  • 从上面的模式创建了 PubSub 主题
  • 创建了具有上述相同架构的 BQ 表
  • 创建了 PubSub 到 BQ 表订阅

更新了客户端

客户端开始向主题发送 avro 消息,并且流向 BQ 的情况良好。

改变模式(进化)

添加了新字段并创建了架构修订版

{
  "namespace": "com.value.model",
  "name": "ValuePoint",
  "type" : "record",
  "fields" : [
    {
      "name" : "application_id",
      "type" : "string"
    },
    {
      "name" : "user_id",
      "type" : "string"
    },
    {
      "name" : "new_field",
      "type" : [null, "string"],
      "default" : "null"
    }
  ]
}
  • 还更新了 BQ 表架构
  • 开始使用新字段从客户端发送新数据。
  • 但是BQ表总是将新字段的值显示为空。

问题

  • 当我将默认值传递为空时,我可能在模式的演变方面做错了。但是如果我删除默认值,则会出现此错误
"Revision is incompatible with previous revision: 4179a86e. Failed with error: Presence of non-optional field new_field is inconsistent.
  • 其次,每当我更新架构修订版时,我是否需要创建新的订阅?

我在主题中对 pubsub 模式的设置

google-cloud-platform google-bigquery avro google-cloud-pubsub
1个回答
0
投票

我也面临着同样的问题。我在主题架构 (AVRO) 中添加了一个新的可选字段,并在 GBQ 表中添加了相应的列。现在,主题消息已发布,并在新字段上带有值。然而,即使等待了几个小时,表中的新列也没有被 GBQ 订阅填充。

© www.soinside.com 2019 - 2024. All rights reserved.