QuestionQ212

VerifiedDebugging and Deploying

A data team’s Structured Streaming job calculates running item-sales aggregates to update a downstream marketing dashboard. The marketing team has launched a new promotion and wants to add a field that tracks how many times its promotion code is used for each item. A junior data engineer proposes updating the existing query as shown below; the proposed changes are in bold.

Original query:

Question Image

Proposed query:

Question Image

What additional step must be completed to deploy the proposed query to production?

Explanation

A streaming groupBy(...).agg(...) maintains aggregate state in its checkpoint. Adding another aggregate changes that state schema, and Structured Streaming does not support restarting such a stateful query from the existing checkpoint. A new checkpointLocation is required for the changed query. mergeSchema can allow the sink’s output schema to evolve, but it does not make the prior checkpointed aggregation state compatible.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!