---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.4
alternate:
  - https://ydb.tech/docs/en/recipes/streaming_queries/debug-read.md
  - https://ydb.tech/docs/ru/recipes/streaming_queries/debug-read.md
sourcePath: en/core/recipes/streaming_queries/debug-read.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# Debug reads from a topic

When developing [streaming queries](https://ydb.tech/docs/en/concepts/streaming-query/streaming-query.md), it is often useful to inspect what arrives in a [topic](https://ydb.tech/docs/en/concepts/datamodel/topic.md) without creating a full streaming query. Run a regular `SELECT` with `STREAMING = "TRUE"`.

{% note warning %}

For debugging and inspection only. For production, create streaming queries with [CREATE STREAMING QUERY](https://ydb.tech/docs/en/yql/reference/syntax/create-streaming-query.md).

{% endnote %}

{% note info %}

In the examples, `ydb_source` is a pre-created [external data source](https://ydb.tech/docs/en/concepts/datamodel/external_data_source.md), and `topic_name` / `input_topic` are topics available through it.

{% endnote %}

## Raw reads

Simplest option — read messages in `raw` format without parsing:

```sql
SELECT
    Data
FROM
    ydb_source.topic_name
WITH (
    FORMAT = raw,
    SCHEMA = (
        Data String
    ),
    STREAMING = "TRUE"
)
LIMIT 1
```

`LIMIT` is required; without it the query never completes because it waits for new messages indefinitely.

## JSON parsing

If the topic stores JSON, parse fields directly:

```sql
SELECT
    *
FROM
    ydb_source.topic_name
WITH (
    FORMAT = json_each_row,
    SCHEMA = (
        Time String NOT NULL,
        Level String NOT NULL,
        Host String NOT NULL
    ),
    STREAMING = "TRUE"
)
LIMIT 5
```

## See also

* [Streaming queries](https://ydb.tech/docs/en/concepts/streaming-query/streaming-query.md)
* [Topic read and write formats](https://ydb.tech/docs/en/dev/streaming-query/streaming-query-formats.md) — supported data formats
* [Streaming read from a topic](https://ydb.tech/docs/en/yql/reference/syntax/select/streaming.md) — `STREAMING = "TRUE"` in the YQL reference
