Bird
0
0

Identify the error in this Kappa architecture streaming code snippet using Kafka and Spark:

medium📝 Debug Q14 of 15
Hadoop - Modern Data Architecture with Hadoop

Identify the error in this Kappa architecture streaming code snippet using Kafka and Spark:

stream_df = spark.readStream.format('kafka') \
  .option('kafka.bootstrap.servers', 'localhost:9092') \
  .option('subscribe', 'events') \
  .load()

value_df = stream_df.selectExpr('CAST(value AS STRING)')

query = value_df.writeStream.outputMode('complete').format('console').start()

query.awaitTermination()

What is the problem?

AOutput mode 'complete' is invalid for streaming without aggregation
BMissing schema definition causes failure
CKafka server address is incorrect
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check output mode usage

    Output mode 'complete' requires aggregation queries to output full results.
  2. Step 2: Analyze query type

    This query only selects and casts values without aggregation, so 'complete' mode is invalid.
  3. Final Answer:

    Output mode 'complete' is invalid for streaming without aggregation -> Option A
  4. Quick Check:

    'complete' mode needs aggregation [OK]
Quick Trick: 'complete' mode only with aggregation queries [OK]
Common Mistakes:
  • Assuming missing schema causes error
  • Thinking Kafka address is wrong
  • Believing code runs without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Hadoop Quizzes