0
0
Kafkadevops~20 mins

Schema compatibility rules in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Schema Compatibility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this compatibility check?

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"}]}
ARegistration succeeds because adding a field with a default value is backward compatible.
BRegistration fails because removing fields is not allowed in backward compatibility.
CRegistration fails because adding a new field without a default value breaks backward compatibility.
DRegistration succeeds because adding any field is always compatible.
Attempts:
2 left
💡 Hint

Backward compatibility means new schema can read data written with the old schema.

Predict Output
intermediate
2:00remaining
What error occurs when registering incompatible schema in FORWARD mode?

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

ARegistration fails because removing a field breaks forward compatibility.
BRegistration succeeds because forward compatibility ignores removed fields.
CRegistration succeeds because removing a field is forward compatible.
DRegistration fails because adding fields is not allowed in forward compatibility.
Attempts:
2 left
💡 Hint

Forward compatibility means old schema can read data written with the new schema.

🔧 Debug
advanced
2:00remaining
Identify the compatibility mode violation

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": ""}]}
AAdding a new field with a default value is not allowed in full compatibility.
BChanging field name from 'name' to 'fullName' breaks full compatibility.
CRemoving the 'name' field is allowed in full compatibility.
DChanging the record name breaks full compatibility.
Attempts:
2 left
💡 Hint

Full compatibility requires both backward and forward compatibility.

🧠 Conceptual
advanced
2:00remaining
Which compatibility mode allows adding optional fields with defaults?

Which Kafka schema compatibility mode permits adding new fields with default values without breaking compatibility?

AFORWARD compatibility
BNONE compatibility
CFULL compatibility
DBACKWARD compatibility
Attempts:
2 left
💡 Hint

Think about which mode ensures new schemas can read old data.

Predict Output
expert
2:00remaining
How many fields will be present after schema evolution in FULL compatibility?

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?

A3 fields
B1 field
C2 fields
D4 fields
Attempts:
2 left
💡 Hint

Adding a field with a default value is allowed in full compatibility.