无法从avro主题创建kafka流

时间:2020-05-15 05:11:11

标签: apache-kafka ksqldb

我正在尝试从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"

1 个答案:

答案 0 :(得分:0)

更多地考虑了这一点-他们没有使用相同的解串器。

PRINT解串器从数据的开头提取用于序列化数据的模式的ID。

CREATE STREAM将在处理任何数据之前(在所有主题都为空之后)联系模式注册中心,并要求其提供主题'-value or dev的模式。 .users-value`。

因此,看起来情况是,Kafka中的数据以一个模式的模式ID为前缀,而在dev.users-value主题下注册的模式是另一个模式。

Schema Registry支持不同的“主题命名策略”。 KsqlDB仅与默认的“ TopicNameStrategy”一起使用。如果有可能为此数据配置了其他策略。有关更多信息,请参见https://docs.confluent.io/current/schema-registry/serdes-develop/index.html#sr-schemas-subject-name-strategy