StreamingQuery
Defined in: streaming/streaming-query.ts:48
Handle for a streaming query running on the Spark Connect server. Returned by DataStreamWriter.start and DataStreamWriter.toTable.
Properties (id, runId, name) are cached from the start response.
Methods (status, lastProgress, stop, and so on) each issue a
StreamingQueryCommand RPC.
isActive is asynchronous on this client even though PySpark and Scala
expose it as a synchronous property. Every other inspection method on this
class crosses the wire; a synchronous getter would lie about its source of
truth.
Spark source: StreamingQuery.scala
Properties
Section titled “Properties”readonly id: string;Defined in: streaming/streaming-query.ts:50
readonly name: string | undefined;Defined in: streaming/streaming-query.ts:52
readonly runId: string;Defined in: streaming/streaming-query.ts:51
Methods
Section titled “Methods”awaitTermination()
Section titled “awaitTermination()”awaitTermination(timeoutMs?): Promise<boolean | undefined>;Defined in: streaming/streaming-query.ts:155
Block until the query terminates.
- With
timeoutMs: returnstrueif the query terminated within the timeout,falseotherwise. - Without a timeout: blocks forever and returns
undefinedonce the query terminates.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
timeoutMs? |
number |
Returns
Section titled “Returns”Promise<boolean | undefined>
Remarks
Section titled “Remarks”The timeout is in milliseconds, matching the Scala client and the
Spark Connect timeout_ms wire field. PySpark’s awaitTermination
takes seconds, so porting awaitTermination(10) from PySpark gives
10ms here, not 10s. Pass 10_000 for the PySpark 10 equivalent.
Throws
Section titled “Throws”SparkConnectError if the query terminated with an exception.
exception()
Section titled “exception()”exception(): Promise< | StreamingQueryException| null>;Defined in: streaming/streaming-query.ts:104
The exception that terminated the query, or null if the query is
still running or stopped cleanly.
Returns
Section titled “Returns”Promise<
| StreamingQueryException
| null>
explain()
Section titled “explain()”explain(extended?): Promise<string>;Defined in: streaming/streaming-query.ts:120
Logical and physical plan as a string. extended=true adds the analyzed
and optimized plans.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
extended? |
boolean |
Returns
Section titled “Returns”Promise<string>
isActive()
Section titled “isActive()”isActive(): Promise<boolean>;Defined in: streaming/streaming-query.ts:63
Whether the query is still running.
Returns
Section titled “Returns”Promise<boolean>
lastProgress()
Section titled “lastProgress()”lastProgress(): Promise< | StreamingQueryProgress| null>;Defined in: streaming/streaming-query.ts:84
Most recent progress report, or null if no batch has been processed yet.
Returns
Section titled “Returns”Promise<
| StreamingQueryProgress
| null>
processAllAvailable()
Section titled “processAllAvailable()”processAllAvailable(): Promise<void>;Defined in: streaming/streaming-query.ts:135
Block until all currently-available source data has been processed and committed to the sink. Useful in tests; do not use in production code with unbounded sources.
Returns
Section titled “Returns”Promise<void>
recentProgress()
Section titled “recentProgress()”recentProgress(): Promise<StreamingQueryProgress[]>;Defined in: streaming/streaming-query.ts:95
Recent progress reports, oldest first. The server keeps a bounded number (default 100); older entries fall off.
Returns
Section titled “Returns”Promise<StreamingQueryProgress[]>
status()
Section titled “status()”status(): Promise<StreamingQueryStatus>;Defined in: streaming/streaming-query.ts:68
Current runtime status (message, data availability, trigger activity).
Returns
Section titled “Returns”Promise<StreamingQueryStatus>
stop()
Section titled “stop()”stop(): Promise<void>;Defined in: streaming/streaming-query.ts:126
Stop the query. Returns after the server confirms termination.
Returns
Section titled “Returns”Promise<void>