JSON负载:
{
"BILLING_EVENT_RULE_MET_DT": "lsks",
"PlanType":"hhh"
}AVRO模式:
{
"name": "Subscription",
"type":"record",
"doc": "Subscription details",
"fields":
[
{ "name": "BILLING_EVENT_RULE_MET_DT", "type":[ "null","string"],"default": null },
{"name": "PlanType",
"type":
{
"name":"PlanType",
"type": "fixed",
"size": 4
}
}
]
}
ERROR:
The value [hhh] for field [PlanType] should be [FixedType <size: 4, name: PlanType, namespace: None, aliases: None>].当验证它给了我以下错误时,我应该在PlanType的json有效负载字段中写什么?实际上,这就是我正在探索的所有内容,因为我想在AVRO schema中定义类似于XML schema的字段的maxlength和minlength。
发布于 2019-12-01 17:38:09
如果"PlanType“的字段大小不是常量,则不能使用”fixed“类型。
如果数据是字符串,则可以使用' string‘类型;如果数据类型是任何字节序列,则可以使用' bytes’类型。
请注意,使用'string‘或' bytes’意味着它不能没有字符/零字节。
要启用空值,应使用联合类型(即“null”和“string”的联合或“null”和“bytes”的联合)。
没有办法将最小大小或最大大小作为avro架构的一部分。请参阅avro specification了解这一点。
https://stackoverflow.com/questions/59078665
复制相似问题