Bird
Raised Fist0
Kafkadevops~20 mins

Schema compatibility rules in Kafka - Practice Problems & Coding Challenges

Choose your learning style10 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.

Practice

(1/5)
1. What does the BACKWARD compatibility rule in Kafka Schema Registry ensure?
easy
A. Both old and new schemas can read each other's data
B. Old schema can read data produced with the new schema
C. No compatibility checks are enforced
D. New schema can read data produced with the previous schema

Solution

  1. Step 1: Understand BACKWARD compatibility meaning

    BACKWARD compatibility means new schema can read data written with the old schema.
  2. Step 2: Compare options with definition

    New schema can read data produced with the previous schema matches this definition exactly, others describe different rules.
  3. Final Answer:

    New schema can read data produced with the previous schema -> Option D
  4. Quick Check:

    BACKWARD = New reads old [OK]
Hint: Backward means new schema reads old data [OK]
Common Mistakes:
  • Confusing backward with forward compatibility
  • Thinking backward means old reads new
  • Assuming no compatibility checks
2. Which of the following is the correct way to set schema compatibility to FULL using Kafka Schema Registry REST API?
easy
A. POST /config -d '{"compatibilityLevel": "FULL"}'
B. PUT /config -d '{"compatibilityLevel": "FULL"}'
C. PUT /config -d '{"compatibility": "FULL"}'
D. GET /config -d '{"compatibility": "FULL"}'

Solution

  1. Step 1: Identify correct HTTP method and endpoint

    Setting compatibility uses PUT on /config endpoint.
  2. Step 2: Check correct JSON field name

    The field is "compatibilityLevel", not "compatibility".
  3. Final Answer:

    PUT /config -d '{"compatibilityLevel": "FULL"}' -> Option B
  4. Quick Check:

    PUT + compatibilityLevel = FULL [OK]
Hint: Use PUT and compatibilityLevel field [OK]
Common Mistakes:
  • Using POST instead of PUT
  • Using wrong JSON field name
  • Using GET method to set config
3. Given the following schemas, which is the most restrictive compatibility rule that will allow the new schema to be registered without error?

Old schema: {"type": "record", "name": "User", "fields": [{"name": "name", "type": "string"}]}
New schema: {"type": "record", "name": "User", "fields": [{"name": "name", "type": "string"}, {"name": "age", "type": ["null", "int"], "default": null}]}
medium
A. FULL
B. FORWARD
C. NONE
D. BACKWARD

Solution

  1. Step 1: Analyze schema change

    The new schema adds a field with a default value, which is backward and forward compatible.
  2. Step 2: Determine compatibility rules allowing this

    FULL compatibility requires both backward and forward compatibility, which this change satisfies.
  3. Final Answer:

    FULL -> Option A
  4. Quick Check:

    Adding default field = FULL compatible [OK]
Hint: Adding default fields supports full compatibility [OK]
Common Mistakes:
  • Thinking adding fields breaks backward compatibility
  • Confusing NONE with allowing all changes
  • Ignoring default values in new fields
4. You try to register a new schema that removes a required field from the old schema under BACKWARD compatibility. What is the likely result?
medium
A. Schema registration succeeds without errors
B. Schema registration succeeds but consumers break at runtime
C. Schema registration fails due to compatibility violation
D. Schema registration succeeds but producers reject data

Solution

  1. Step 1: Understand backward compatibility rules

    Backward compatibility requires new schema to read old data, so removing required fields breaks this.
  2. Step 2: Predict schema registry behavior

    Registry rejects schemas violating compatibility rules, so registration fails.
  3. Final Answer:

    Schema registration fails due to compatibility violation -> Option C
  4. Quick Check:

    Removing required field breaks backward = fail [OK]
Hint: Removing required fields breaks backward compatibility [OK]
Common Mistakes:
  • Assuming registration always succeeds
  • Confusing runtime errors with registration errors
  • Thinking producers reject data on schema mismatch
5. You have a Kafka topic with schema compatibility set to FORWARD. You want to add a new optional field to the schema without breaking existing consumers. Which approach should you take?
hard
A. Add the new field with a default value or make it nullable
B. Remove an existing required field to simplify the schema
C. Add the new field without a default value
D. Change the type of an existing field to a different primitive type

Solution

  1. Step 1: Understand FORWARD compatibility

    FORWARD compatibility means old schema can read data written with new schema.
  2. Step 2: Determine safe schema changes

    Adding optional fields with defaults or nullable types preserves forward compatibility.
  3. Step 3: Evaluate options

    Only Add the new field with a default value or make it nullable adds a field safely; others break compatibility or cause errors.
  4. Final Answer:

    Add the new field with a default value or make it nullable -> Option A
  5. Quick Check:

    Forward compatible additions need defaults or nullable [OK]
Hint: Add optional fields with defaults for forward compatibility [OK]
Common Mistakes:
  • Adding required fields without defaults
  • Removing fields under forward compatibility
  • Changing field types without compatibility checks
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard