[英]Pubsub Subscription error for TIMESTAMP data type: Incompatible schema type
[英]PubSub Subscription error with REPEATED Column Type - Avro Schema
我正在尝试使用 PubSub 订阅“写入 BigQuery”,但遇到了“重复”列类型的问题。 更新订阅时收到的消息是
字段“值”的架构模式不兼容:主题架构中的字段是必需的,但在 BigQuery 表架构中是重复的
我的 Avro 架构是:
{
"type": "record",
"name": "Avro",
"fields": [
{
"name": "ItemID",
"type": "string"
},
{
"name": "UserType",
"type": "string"
},
{
"name": "Values",
"type": [
{
"type": "record",
"name": "Values",
"fields": [
{
"name": "AttributeID",
"type": "string"
},
{
"name": "AttributeValue",
"type": "string"
}
]
}
]
}
]
}
输入“匹配”模式的 JSON:
{
"ItemID": "Item_1234",
"UserType": "Item",
"Values": {
"AttributeID": "TEST_ID_1",
"AttributeValue": "Value_1"
}
}
我的表看起来像:
ItemID | STRING | NULLABLE
UserType | STRING | NULLABLE
Values | RECORD | REPEATED
AttributeID | STRING | NULLABLE
AttributeValue | STRING | NULLABLE
我能够“测试”和“验证架构”并且成功返回。 问题是,我在 Avro 上为 Values 节点缺少什么以使其“重复”与“必需”以创建订阅。
问题是 Values 不是 Avro 架构中的数组类型,这意味着它只需要消息中的一个,而它是 BigQuery 架构中的重复类型,这意味着它需要它们的列表。
根据上面 Kamal 的评论,这个模式有效:
{
"type": "record",
"name": "Avro",
"fields": [
{
"name": "ItemID",
"type": "string"
},
{
"name": "UserType",
"type": "string"
},
{
"name": "Values",
"type": {
"type": "array",
"items": {
"name": "NameDetails",
"type": "record",
"fields": [
{
"name": "ID",
"type": "string"
},
{
"name": "Value",
"type": "string"
}
]
}
}
}
]
}
有效载荷:
{
"ItemID": "Item_1234",
"UserType": "Item",
"Values": [
{ "AttributeID": "TEST_ID_1" },
{ "AttributeValue": "Value_1" }
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.