# `SparkEx.StreamingQuery`
[🔗](https://github.com/lukaszsamson/spark_ex/blob/v0.1.1/lib/spark_ex/streaming_query.ex#L1)

Controls a running structured streaming query.

Mirrors PySpark's `StreamingQuery` with methods for monitoring
and controlling the query lifecycle.

## Examples

    {:ok, query} = writer |> SparkEx.StreamWriter.start()
    {:ok, true} = SparkEx.StreamingQuery.is_active?(query)
    :ok = SparkEx.StreamingQuery.stop(query)

# `t`

```elixir
@type t() :: %SparkEx.StreamingQuery{
  name: String.t() | nil,
  query_id: String.t(),
  run_id: String.t(),
  session: GenServer.server()
}
```

# `await_termination`

```elixir
@spec await_termination(
  t(),
  keyword()
) :: {:ok, boolean() | nil} | {:error, term()}
```

Waits for the termination of the query.

## Options

  * `:timeout` — timeout in milliseconds (default: no timeout)

# `exception`

```elixir
@spec exception(t()) :: {:ok, map() | nil} | {:error, term()}
```

Returns exception information if the query has terminated with an error.

# `explain`

```elixir
@spec explain(
  t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}
```

Returns the query plan as a string.

## Options

  * `:extended` — whether to include extended details (default: false)

# `id`

```elixir
@spec id(t()) :: String.t()
```

Returns the streaming query ID.

# `is_active?`

```elixir
@spec is_active?(t()) :: {:ok, boolean()} | {:error, term()}
```

Returns whether the streaming query is currently active.

# `last_progress`

```elixir
@spec last_progress(t()) :: {:ok, String.t() | nil} | {:error, term()}
```

Returns the most recent progress report as a JSON string, or nil.

# `name`

```elixir
@spec name(t()) :: String.t() | nil
```

Returns the streaming query name.

# `process_all_available`

```elixir
@spec process_all_available(t()) :: :ok | {:error, term()}
```

Blocks until all available data in the source has been processed.

# `recent_progress`

```elixir
@spec recent_progress(t()) :: {:ok, [String.t()]} | {:error, term()}
```

Returns a list of recent progress reports as JSON strings.

# `run_id`

```elixir
@spec run_id(t()) :: String.t()
```

Returns the streaming query run ID.

# `status`

```elixir
@spec status(t()) :: {:ok, map()} | {:error, term()}
```

Returns the current status of the streaming query.

# `stop`

```elixir
@spec stop(t()) :: :ok | {:error, term()}
```

Stops the streaming query.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
