Bird
0
0

Given this Kafka Streams topology:

medium📝 Predict Output Q5 of 15
Kafka - Advanced Stream Processing
Given this Kafka Streams topology:
builder.stream("input")
  .mapValues(v -> v.toUpperCase())
  .to("output");
// Input message: key=1, value="hello"
// What is the output message in "output" topic?
Akey=1, value="HELLO"
Bkey=1, value="hello"
Ckey=null, value="HELLO"
Dkey=1, value=null
Step-by-Step Solution
Solution:
  1. Step 1: Understand mapValues transformation

    mapValues changes the message value to uppercase, key remains unchanged.
  2. Step 2: Apply transformation to input

    Input value "hello" becomes "HELLO", key stays 1.
  3. Final Answer:

    key=1, value="HELLO" -> Option A
  4. Quick Check:

    mapValues changes value only [OK]
Quick Trick: mapValues transforms only the value, key stays same [OK]
Common Mistakes:
  • Assuming key changes
  • Confusing mapValues with map
  • Expecting null values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes