0
0
Kafkadevops~20 mins

Transform and converter chains in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Transform Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a Kafka Connect transform chain
Consider a Kafka Connect source connector with the following transform chain applied to each record:

{"transforms": "dropField,replaceValue", "transforms.dropField.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", "transforms.dropField.blacklist": "password", "transforms.replaceValue.type": "org.apache.kafka.connect.transforms.ReplaceField$Value", "transforms.replaceValue.whitelist": "username"}

Given a record with value:
{"username": "alice", "password": "secret", "email": "alice@example.com"}

What will be the value of the record after the transform chain?
A{"password": "secret"}
B{"username": "alice", "email": "alice@example.com"}
C{"email": "alice@example.com"}
D{"username": "alice"}
Attempts:
2 left
💡 Hint
Think about the order of transforms and what each one keeps or removes.
Predict Output
intermediate
2:00remaining
Result of converter chain with JSON and Avro
A Kafka Connect sink connector uses a converter chain where the key converter is JSON and the value converter is Avro. The source sends a record with key:
{"id": 123}

and value:
{"name": "Bob", "age": 30}

What is the expected format of the key and value when the sink receives the record?
AKey as Avro bytes, value as JSON bytes
BBoth key and value as Avro bytes
CKey as JSON bytes, value as Avro bytes
DBoth key and value as JSON bytes
Attempts:
2 left
💡 Hint
Remember the converter chain applies separately to key and value.
🔧 Debug
advanced
2:00remaining
Identify the error in transform chain configuration
A user configures a Kafka Connect transform chain as follows:

{"transforms": "maskField", "transforms.maskField.type": "org.apache.kafka.connect.transforms.MaskField$Value", "transforms.maskField.fields": "ssn"}

But the connector fails to start with an error about transform class not found. What is the most likely cause?
AThe transform chain name 'maskField' is reserved and cannot be used
BThe transform class name is incorrect; it should be MaskField$Key or MaskField$Value with correct casing
CThe 'fields' property is missing a comma-separated list of fields
DThe connector requires a converter to be set before transforms
Attempts:
2 left
💡 Hint
Check the exact class name spelling and casing for the transform.
🧠 Conceptual
advanced
2:00remaining
Understanding transform chain order impact
In Kafka Connect, you have two transforms in a chain:
1. ReplaceField to whitelist only 'user' and 'email'
2. MaskField to mask the 'email' field

If you reverse the order of these transforms, what is the impact on the final record?
AReversing the order causes the MaskField to fail because 'email' is removed before masking
BReversing the order has no impact; the final record is the same
CReversing the order causes the 'user' field to be masked instead of 'email'
DReversing the order causes the connector to crash due to invalid transform chain
Attempts:
2 left
💡 Hint
Think about which fields exist when each transform runs.
Predict Output
expert
3:00remaining
Output of complex converter and transform chain
A Kafka Connect source connector uses the following configuration:

{
  "key.converter": "org.apache.kafka.connect.json.JsonConverter",
  "key.converter.schemas.enable": false,
  "value.converter": "io.confluent.connect.avro.AvroConverter",
  "value.converter.schema.registry.url": "http://localhost:8081",
  "transforms": "unwrap,dropFields",
  "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
  "transforms.dropFields.type": "org.apache.kafka.connect.transforms.ReplaceField$Value",
  "transforms.dropFields.blacklist": "metadata,internal"
}

Given a source record value:
{"before": null, "after": {"id": 1, "name": "John", "metadata": "info", "internal": "secret"}}

What will be the value passed to the sink after the transform chain?
A{"id": 1, "name": "John"}
B{"before": null, "after": {"id": 1, "name": "John"}}
C{"id": 1, "name": "John", "metadata": "info", "internal": "secret"}
D{"metadata": "info", "internal": "secret"}
Attempts:
2 left
💡 Hint
The unwrap transform extracts the 'after' field, then dropFields removes blacklisted fields.