Question 1
In the Kafka source, which column contains the message payload?
Correct answer
value, as binary
Explanation
Kafka source rows include key, value, topic, partition, offset and timestamp; key and value are binary.
databricks Associate Developer for Apache Spark · Practice questions
Review 10 sample questions with their correct answers and explanations. Sign up free to continue with the full topic quiz.
Sign up free for the full quizIn the Kafka source, which column contains the message payload?
value, as binary
Kafka source rows include key, value, topic, partition, offset and timestamp; key and value are binary.
Which three elements together allow Structured Streaming to achieve end-to-end exactly-once guarantees?
Replayable sources, checkpoints and idempotent sinks
Exactly-once requires sources that can replay data, offsets and state saved in the checkpoint, and sinks that handle replays safely.
Which code defines sliding windows of 10 minutes that start every 5 minutes?
window('event_time', '10 minutes', '5 minutes')
The second argument is the window duration and the third is the slide duration.
Which statement about a stateful operator in Structured Streaming is correct?
It keeps checkpointed state across micro-batches
Stateful operators such as streaming aggregations, deduplication and arbitrary state functions keep state in a state store on executors, checkpointed for fault tolerance.
Which code defines a watermark of 15 minutes on the column event_time?
df.withWatermark('event_time', '15 minutes')
withWatermark(eventTimeColumn, delayThreshold) defines how late data may arrive before state is dropped.
Which code stops a running streaming query referenced by q?
q.stop()
StreamingQuery.stop() stops the query; awaitTermination waits for it.
Which code reads a Kafka topic as a stream?
spark.readStream.format('kafka').option('kafka.bootstrap.servers', servers).option('subscribe', 'orders').load()
The Kafka source requires bootstrap servers and a subscription option; the value column holds the message payload as binary.
Which code creates a streaming DataFrame from JSON files arriving in a folder, with an explicit schema?
spark.readStream.schema(schema).json('/data/incoming')
readStream returns a DataStreamReader. File sources require a schema unless schema inference for streaming is enabled.
Which sink is meant only for debugging, printing each micro-batch to stdout?
console
The console sink prints results and is not fault tolerant; use it for testing only.
Which PySpark API applies arbitrary stateful processing per group in a streaming query using pandas?
applyInPandasWithState
applyInPandasWithState (and newer transformWithStateInPandas) supports custom stateful logic per key in streaming queries.
Create a free QuizAnalyst account to practice the complete question set and save your progress.
Sign up free for the full quiz