Databricks Certified Associate Developer for Apache Spark — Question 199
A data engineer wants to create a Streaming DataFrame that reads from a Kafka topic called 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 inserted in line 5 to meet the requirement?
Answer options
- A. .option("subscribe", "feed")
- B. .option("subscribe.topic", "feed")
- C. .option("kafka.topic", "feed")
- D. .option(“topic”, “feed”)
Correct answer: A
Explanation
The correct answer is A because the 'subscribe' option is specifically designed to specify the topic name in Kafka. The other options either use incorrect option names or formats that are not recognized by the Kafka source in Spark.