Aggregating a stream over sliding or tumbling time windows
Windowing (analytic) functions let you compute ranks, running totals, and row-to-row comparisons across a set of related rows without collapsing them into groups, using the OVER() clause with PARTITION BY and ORDER BY. In Fabric, you create these using Spark SQL/PySpark in notebooks or T-SQL in the Warehouse/SQL endpoint, applying functions like ROW_NUMBER, RANK, LAG/LEAD, and aggregate-over-window patterns.
1 · Learn the must-know
- The OVER() clause defines the window: PARTITION BY groups rows (like GROUP BY but keeps all rows), and ORDER BY defines the sequence within each partition for ranking and offset functions.
ROW_NUMBERalways assigns unique sequential integers even for ties, RANK skips numbers after ties, andDENSE_RANKdoes not skip numbers after ties: choose based on whether gaps are desired.- LAG and LEAD access prior/following row values within a partition and require an ORDER BY; an optional offset and default value can be specified for rows without a match.
- Aggregate functions (SUM, AVG, COUNT, MIN, MAX) become window functions when combined with OVER(), enabling running totals or moving averages without a GROUP BY.
- Frame specifications (ROWS BETWEEN / RANGE BETWEEN, e.g., UNBOUNDED PRECEDING AND CURRENT ROW) control exactly which rows within the partition are included in the calculation for each row.
- In PySpark, window specs are built with the Window class (Window.partitionBy(...).orderBy(...)) and passed to functions like
F.row_number().over(windowSpec); in Fabric Warehouse T-SQL, the same OVER()/PARTITION BY/ORDER BY syntax as SQL Server/Synapse applies.
2 · Check your understanding
A data engineer working in a Fabric notebook needs to keep only the most recent transaction for each account_id from a Delta table that contains many historical rows per account. Some accounts have multiple transactions with the exact same transaction_date. The engineer starts with:
window_spec = Window.partitionBy('account_id').orderBy(col('transaction_date').desc())
df_ranked = df.withColumn('rn', ???)
df_latest = df_ranked.filter(col('rn') == 1)
Which function should replace ??? so that exactly one row per account_id is kept, even for accounts whose latest transactions share the same transaction_date?
What you have tried across DP-700's objectives, not a readiness score.
Implement and manage an analytics solution30-35% of the exam0 of 18 tried
Ingest and transform data30-35% of the exam0 of 19 tried
Monitor and optimize an analytics solution30-35% of the exam0 of 17 tried
3 · Keep going
Ready for more? Take a weighted mock or try free practice questions.