Given a schema registry with BACKWARD compatibility mode, what will happen if you try to register this new schema?
{"type": "record", "name": "User", "fields": [{"name": "name", "type": "string"}, {"name": "age", "type": "int"}]}Original schema was:
{"type": "record", "name": "User", "fields": [{"name": "name", "type": "string"}]}Backward compatibility means new schema can read data written with the old schema.
Adding a new field without a default value breaks backward compatibility because old data won't have that field, causing read errors.
Original schema:
{"type": "record", "name": "Product", "fields": [{"name": "id", "type": "int"}, {"name": "price", "type": "float"}]}New schema:
{"type": "record", "name": "Product", "fields": [{"name": "id", "type": "int"}]}Compatibility mode: FORWARD
Forward compatibility means old schema can read data written with the new schema.
Removing a field breaks forward compatibility because old readers expect that field but new data won't have it.
Given the following original and new schemas, and the compatibility mode set to FULL, which change causes the registration to fail?
Original schema:
{"type": "record", "name": "Employee", "fields": [{"name": "id", "type": "int"}, {"name": "name", "type": "string"}]}
New schema:
{"type": "record", "name": "Employee", "fields": [{"name": "id", "type": "int"}, {"name": "fullName", "type": "string", "default": ""}]}Full compatibility requires both backward and forward compatibility.
Renaming a field is not backward or forward compatible because readers expect the original field name.
Which Kafka schema compatibility mode permits adding new fields with default values without breaking compatibility?
Think about which mode ensures new schemas can read old data.
Backward compatibility allows adding new fields with defaults because old data can still be read by the new schema.
Original schema:
{"type": "record", "name": "Order", "fields": [{"name": "orderId", "type": "int"}, {"name": "amount", "type": "float"}]}New schema:
{"type": "record", "name": "Order", "fields": [{"name": "orderId", "type": "int"}, {"name": "amount", "type": "float"}, {"name": "discount", "type": "float", "default": 0.0}]}Compatibility mode: FULL
After evolution, how many fields will the new schema have?
Adding a field with a default value is allowed in full compatibility.
The new schema adds one field with a default value, so total fields become 3.