Add transformWithState Python async guidance to structured streaming skill - #242
Open
jiteshsoni wants to merge 3 commits into
Open
Add transformWithState Python async guidance to structured streaming skill#242jiteshsoni wants to merge 3 commits into
jiteshsoni wants to merge 3 commits into
Conversation
…skill Agents keep repeating failed TWS experiments (exists-then-get, always-iterator, autoscale A/B). Put API facts and copy-paste async MapState patterns in a new reference so they stop. Signed-off-by: Jitesh Soni <jitesh.soni+data@databricks.com>
jiteshsoni
requested review from
lennartkats-db and
simonfaltum
as code owners
August 13, 2026 03:46
added 2 commits
August 12, 2026 21:08
The TWS async guidance was not validated in Real-Time Mode; keep the new reference linked from SKILL.md and stateful-operations.md only.
…Tester, initial state, TTL granularity).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Without this reference, agents re-run the same
transformWithState(TWS) experiments:exists()thenget(), sequentialawait getValue, “always useiterator()”, collapsing a largeMapStateintoValueState(Array), and A/B jobs on autoscale 1–N workers (wall-clock is noise). Those paths fail or look like wins until they are measured on a fixed-size cluster.This PR extends
skills/databricks-spark-structured-streaming/with a new reference rather than a top-level skill:skills/databricks-spark-structured-streaming/references/transform-with-state.md— API facts + copy-paste Python:StatefulProcessor(Spark 4.0+ / DBR 16.2+).AsyncStatefulProcessoris a gated Databricks Beta (DBR 19+, classic/assigned compute only — not OSS, not serverless)ValueState.update/MapState.updateValuetake a positional tuple (not a dict; same-arity dict can silently write keys as values)now + duration); TTL viattlDurationMsint (noTTLConfig); per ListState value / per MapState entry; no TTL with EventTime (eventTimeColumnNamerequired)asyncio.gather(getValue)is concurrent/batched IPC; documentedasync for k, v in self.rows.iterator(); 64 / 400 / 20k / 500k are starting points to measure, not Spark defaultsValueState; explicit memory ceilings; re-key fat 100k-row keysinitialState=is GroupedData (batch_df.groupBy(same keys));handleInitialState(key, initialState, timerValues)statestorereader via.load(path); TwsTester on sync processors only (cannot drive async)SKILL.mdCore Patternsstateful-operations.md(no duplicated TWS body)Generated
manifest.json+plugins/databricks/*copies viapython3 scripts/skills.py generate(required by CI).Test plan
python3 scripts/skills.py validatepasses locallytransform-with-state.mdlength (~2k words, peer of other references in the folder — not a wholesale paste of a 1300-line guide)gather(getValue), documentedasync foriterator, timer replace (now_ms + duration_ms),update((n,))