redpanda-data / redpanda

Redpanda is a streaming data platform for developers. Kafka API compatible. 10x faster. No ZooKeeper. No JVM!
https://redpanda.com
9.46k stars 579 forks source link

[CORE-3183] schema registry json compatibility checks for primitive types #19851

Closed andijcr closed 3 months ago

andijcr commented 3 months ago

Implementation of bool check_compatible(const json_schema_definition& reader, const json_schema_definition& writer); for string, numeric JSON types, to allow checking compatibility of a subset of JSON schema draft 4

The checking is done by traversing both schemas, looking for a rule in the writer schema that is less strict than its counterpart in the reader schema. If no such rule is found, then the result is true

Fixes: https://redpandadata.atlassian.net/browse/CORE-3183

Backports Required

Release Notes

andijcr commented 3 months ago

Looks ok in principal.

1. Maybe a `std::bitset` is a nicer than a `std::set<enum>`

I went with absl::InlinedVector because performing a set difference with bitset looks a bit more obscure

andijcr commented 3 months ago

force push: addressed most of the review comments

andijcr commented 3 months ago

force push: other review comments

andijcr commented 3 months ago

fixed unnecessary json::Value copy in normalized_type