You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Jiwon Park (Jira)" <ji...@apache.org> on 2026/07/30 11:48:00 UTC

[jira] [Created] (SPARK-58447) Preserve operation tags in Spark Connect Python foreachBatch callbacks

Jiwon Park created SPARK-58447:
----------------------------------

             Summary: Preserve operation tags in Spark Connect Python foreachBatch callbacks
                 Key: SPARK-58447
                 URL: https://issues.apache.org/jira/browse/SPARK-58447
             Project: Spark
          Issue Type: Bug
          Components: Connect
    Affects Versions: 5.0.0
            Reporter: Jiwon Park


Spark Connect does not preserve operation tags from the `writeStream.start()` request in Python `foreachBatch` callbacks.

The callback runs in a separate Python worker that creates a local Connect client. Because operation tags are client thread-local, the callback session does not contain the tags from the originating request. Consequently, nested actions such as `count`, writes, and SQL commands are executed without those tags.

A minimal reproduction is:

spark.addTag("foreach-batch")

def process_batch(df, _):
    assert "foreach-batch" in df.sparkSession.getTags()
    df.count()

query = stream.writeStream.foreachBatch(process_batch).start()
query.processAllAvailable()

The assertion fails with Spark Connect. The callback session should inherit the operation tags captured when the streaming query starts.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org