
Ultimate access to all questions.
Which of the following Structured Streaming queries is performing a hop from a Silver table to a Gold table?
A
(spark.readStream.load(rawSalesLocation)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
(spark.readStream.load(rawSalesLocation)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
B
(spark.read.load(rawSalesLocation)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
(spark.read.load(rawSalesLocation)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
C
(spark.table("sales")
.withColumn("avgPrice", col("sales") / col("units"))
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
(spark.table("sales")
.withColumn("avgPrice", col("sales") / col("units"))
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
D
(spark.table("sales")
.filter(col("units") > 0)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
(spark.table("sales")
.filter(col("units") > 0)
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("append")
.table("newSales"))
E
(spark.table("sales")
.groupBy("store")
.agg(sum("sales"))
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("complete")
.table("newSales"))
(spark.table("sales")
.groupBy("store")
.agg(sum("sales"))
.writeStream
.option("checkpointLocation", checkpointPath)
.outputMode("complete")
.table("newSales"))
Explanation:
In the Databricks Lakehouse architecture:
A "hop" from Silver to Gold table typically involves aggregation and transformation of cleaned data into business-ready aggregates. Let's analyze each option:
Option A: Reads from rawSalesLocation (likely Bronze) and writes to newSales - this is a Bronze to Silver hop.
Option B: Uses spark.read.load() (batch read) with writeStream - this is incorrect syntax and doesn't represent a Silver to Gold hop.
Option C: Reads from sales table (Silver), performs a simple transformation (avgPrice calculation), and writes to newSales - this is a transformation but not necessarily aggregation for Gold tables.
Option D: Reads from sales table (Silver), filters data, and writes to newSales - this is filtering but not aggregation.
Option E: Reads from sales table (Silver), performs aggregation (groupBy and sum), and writes to newSales with outputMode("complete") - this is a classic Silver to Gold hop where aggregated business metrics are created from cleaned data.
The key indicators of a Silver to Gold hop are:
outputMode("complete") for aggregated results (common for Gold tables)Therefore, Option E correctly represents a Structured Streaming query performing a hop from a Silver table to a Gold table.