无法从avro主题创建kafka流

qvk1mo1f  于 2021-06-05  发布在  Kafka
关注(0)|答案(1)|浏览(450)

我试图从一个kafka主题创建一个流,该主题的值格式和键格式都是avro,下面是在这个主题上运行ksql print的示例:

Key format: AVRO
Value format: AVRO
rowtime: 2020/05/15 04:49:30.979 Z,
key:{
   "_id":{
      "_data":"825EBE1F57000000022B022C0100296E5A1004514E195BA8044B299EF9653C8B8A16D346645F696400645EBE1F572597108CA0F285D70004"

}
},
value:{
   "_id":{
      "_data":"825EBE1F57000000022B022C0100296E5A1004514E195BA8044B299EF9653C8B8A16D346645F696400645EBE1F572597108CA0F285D70004"

},
   "operationType":"insert",
   "clusterTime":{
      "$timestamp":{
         "t":1589518167,
         "i":2

}

},
   "fullDocument":{
      "_id":{
         "$oid":"5ebe1f572597108ca0f285d7"

},
      "ok":2.0

},
   "ns":{
      "db":"dev",
      "coll":"users"

},
   "documentKey":{
      "_id":{
         "$oid":"5ebe1f572597108ca0f285d7"

}

}
}

我正在执行以下命令:

create stream s with(kafka_topic='dev.users', value_format='avro');

当我这么做的时候,我有以下错误:

Unable to verify if the schema for topic dev.users is compatible with KSQL.
Reason: KSQL stream/table schema must be structured

Please see https://github.com/confluentinc/ksql/issues/ to see if this particular reason is already known.
If not, please log a new issue, including the this full error message.
Schema:"string"
qco9c6ql

qco9c6ql1#

更深入地研究了这一点-它们不使用相同的反序列化程序。
打印反序列化程序从数据的开头提取用于序列化数据的架构的id。
create流将在处理任何数据之前联系schema注册表(毕竟主题可能为空!),并要求它提供主题值的模式 or dev.users-value在您的情况下。 所以它看起来像是kafka中的数据以一个schema的schema id作为前缀,而这个schema注册在dev.users-value` 主题是另一种模式。
架构注册表支持不同的“主题命名策略”。ksqldb只适用于默认的“topicnamestractegy”。如果可能是为该数据配置了其他策略。看到了吗https://docs.confluent.io/current/schema-registry/serdes-develop/index.html#sr-有关详细信息,请参阅主题名称策略。

相关问题