QuestionQ191

VerifiedStructured Streaming

A data engineer needs to create a Streaming DataFrame that reads from a Kafka topic named feed.

  1. spark
  2. .readStream
  3. .format("kafka")
  4. .option("kafka.bootstrap.servers", "host1:port1,host2:port2")
  5. ._____________
  6. .load()

Which code fragment should be added on line 5 to satisfy the requirement?

Explanation

For a Structured Streaming Kafka source, the subscribe option specifies a comma-separated list of topics to consume. Setting it to feed subscribes the Streaming DataFrame to that topic. The topic option is used when writing to a Kafka sink, not when selecting a source topic.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!