A data engineering team has an existing production Spark Structured Streaming job written in PySpark that reads from Delta Lake, applies a stateful sessionization window function using flatMapGroupsWithState, and writes results to a Gold Delta table. The team is evaluating migrating this job to Lakeflow Spark Declarative Pipelines. A senior engineer raises concerns about whether Lakeflow SDP can support all the features required. Which statement MOST accurately describes the capabilities and limitations of Lakeflow SDP compared to the team's direct Structured Streaming job for this specific use case?
Show answer & explanation
Correct answer: E
WHY E: This is the accurate and honest assessment. Lakeflow SDP is built on Spark Structured Streaming and handles the vast majority of streaming ETL patterns extremely well — but it is a declarative framework that constrains table definitions to SQL-expressible or DataFrame API patterns that fit its table update model. flatMapGroupsWithState is a low-level stateful operator that manages arbitrary per-key state across micro-batches using a custom user-defined state transition function. This type of arbitrary stateful processing does not map cleanly to Lakeflow SDP's Streaming Table or Materialized View constructs. For such cases, direct Structured Streaming gives the team full control over all streaming operators. The correct guidance is to use Lakeflow SDP for the majority of pipeline logic and fall back to direct Structured Streaming when custom stateful operators are required. WHY NOT A: While @dlt.table functions do receive a streaming DataFrame, Lakeflow SDP's framework imposes constraints on what operators can be applied — arbitrary stateful operators like flatMapGroupsWithState are not supported within the declarative pipeline execution model. WHY NOT C: Lakeflow SDP is not a replacement streaming engine — it runs on top of Spark Structured Streaming. It does not replace SSA internally, and flatMapGroupsWithState is not available within pipeline table definitions. WHY NOT D: APPLY CHANGES INTO is for CDC (insert/update/delete from a change stream), not for arbitrary sessionization window logic. The SEQUENCE BY clause determines event ordering for CDC operations, not custom stateful window computations. WHY NOT B: Lakeflow SDP's management overhead does not add 15–30% query latency. The metadata and lineage operations are asynchronous and do not block query execution paths.