0
0
Kafkadevops~20 mins

Schema evolution (backward, forward, full) in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Schema Evolution Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output when a consumer with an older schema reads a message with a newer schema?

Consider a Kafka topic using Avro serialization with schema evolution enabled. The producer adds a new optional field to the schema. The consumer uses the older schema without this new field. What happens when the consumer reads the message?

Kafka
Producer schema v2: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["null","int"],"default":null}]}
Consumer schema v1: {"type":"record","name":"User","fields":[{"name":"name","type":"string"}]}
AThe consumer reads the message but sets 'age' to zero by default.
BThe consumer throws a serialization error due to the missing 'age' field.
CThe consumer blocks and waits for a schema update.
DThe consumer reads the message successfully, ignoring the new 'age' field.
Attempts:
2 left
💡 Hint

Think about forward compatibility: can an older consumer read data produced with the newer schema?

Predict Output
intermediate
2:00remaining
What happens when a producer sends data with an older schema and the consumer expects a newer schema?

A Kafka consumer expects a schema with a new required field added (no default). The producer sends data using the older schema without this field. What is the result when the consumer tries to deserialize the message?

Kafka
Producer schema v1: {"type":"record","name":"User","fields":[{"name":"name","type":"string"}]}
Consumer schema v2: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"email","type":"string"}]}
AThe consumer throws a deserialization error due to the missing 'email' field.
BThe consumer sets 'email' to an empty string by default.
CThe consumer ignores the missing 'email' field and reads the message.
DThe consumer reads the message but sets 'email' to null.
Attempts:
2 left
💡 Hint

Consider backward compatibility and required fields without defaults.

🧠 Conceptual
advanced
1:30remaining
Which schema evolution mode allows both backward and forward compatibility?

In Kafka schema registry, which compatibility mode ensures that schemas are compatible both backward and forward?

AFull compatibility
BForward compatibility
CNo compatibility
DBackward compatibility
Attempts:
2 left
💡 Hint

Think about the mode that combines both backward and forward compatibility.

Predict Output
advanced
2:00remaining
What error occurs if a required field is removed in a new schema version?

A Kafka topic uses Avro schemas. The original schema has fields 'name' and 'age' (both required). The new schema removes the 'age' field. What happens when the new schema is registered with full compatibility enabled?

Kafka
Original schema: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":"int"}]}
New schema: {"type":"record","name":"User","fields":[{"name":"name","type":"string"}]}
ASchema registry accepts the new schema but warns about data loss.
BSchema registry accepts the new schema without errors.
CSchema registry rejects the new schema due to incompatibility.
DSchema registry accepts the new schema only if 'age' has a default.
Attempts:
2 left
💡 Hint

Removing required fields breaks forward compatibility.

🔧 Debug
expert
3:00remaining
Why does this schema registration fail under backward compatibility?

Given the original schema and a new schema, the new schema registration fails under backward compatibility. Identify the cause.

Kafka
Original schema: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":["null","int"],"default":null}]}
New schema: {"type":"record","name":"User","fields":[{"name":"name","type":"string"},{"name":"age","type":"int"}]}
AThe new schema adds a new required field without a default.
BThe new schema removes the default for 'age', breaking backward compatibility.
CThe new schema changes the type of 'name' field.
DThe new schema adds an optional field with a default.
Attempts:
2 left
💡 Hint

Check changes in field defaults and types.