Bird
0
0

What is wrong with this Kafka Streams code snippet?

medium📝 Debug Q7 of 15
Kafka - Advanced Stream Processing
What is wrong with this Kafka Streams code snippet?
StreamsBuilder builder = new StreamsBuilder();
KStream stream = builder.stream("input");
stream.filter((k, v) -> v.length() > 5);
stream.to("output");
AFilter result is not assigned or used before to()
Bto() method is called on wrong stream type
CFilter condition syntax is invalid
DStreamsBuilder cannot create KStream
Step-by-Step Solution
Solution:
  1. Step 1: Analyze stream transformations

    filter returns a new KStream; original stream is unchanged.
  2. Step 2: Check usage of filtered stream

    Filtered stream is not assigned or used; to() is called on original stream.
  3. Final Answer:

    Filter result is not assigned or used before to() -> Option A
  4. Quick Check:

    Always use filtered stream for further operations [OK]
Quick Trick: Assign filtered stream before calling to() [OK]
Common Mistakes:
  • Assuming filter modifies original stream
  • Thinking to() is invalid here
  • Believing filter syntax is wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes