> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chowder.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# read_mcap

> Read MCAP robotics logs as a SQL table, one row per message.

`read_mcap` reads MCAP robotics and sensor logs and returns one row per message. Each row keeps the original message bytes in `data`, the decoded message as JSON in `decoded`, and any camera image in `image`.

Chowder decodes JSON, Protobuf, ROS 1, and ROS 2 CDR messages when the file embeds a usable schema.

## Signature

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
read_mcap(pattern)
```

| Parameter | Type | Description |
| - | - | - |
| `pattern` | `VARCHAR` | An MCAP file, directory, glob, or supported remote URI. |

Supported extension: `.mcap`.

## Example

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    log_time,
    topic,
    schema_name,
    decoded,
    decode_error
FROM read_mcap('hf://buckets/chowderai/chowder-demo/mcap/data/road-spray-car-following.mcap')
WHERE topic = '/camera/annotations'
LIMIT 5;
```

## Columns

| Column | Type | Description |
| - | - | - |
| `source` | `VARCHAR` | Input path or URI. |
| `profile` | `VARCHAR` | MCAP profile from the file header. |
| `library` | `VARCHAR` | Producer library from the file header. |
| `topic` | `VARCHAR` | Channel topic. |
| `channel_id` | `SMALLINT UNSIGNED` | Channel identifier. |
| `sequence` | `INT UNSIGNED` | Message sequence number. |
| `log_time`, `publish_time` | `TIMESTAMP_TZ(9, 'UTC')` | Timestamps in the file's time base, usually UTC, when the value fits the timestamp range. |
| `log_time_ns`, `publish_time_ns` | `BIGINT UNSIGNED` | Exact timestamps, in nanoseconds. |
| `message_encoding` | `VARCHAR` | Message serialization encoding. |
| `channel_metadata` | `ARRAY<STRUCT<key VARCHAR, value VARCHAR>>` | Channel key/value metadata. |
| `file_metadata` | `VARCHAR` | File-level MCAP metadata records, as JSON. |
| `schema_id` | `SMALLINT UNSIGNED` | Optional schema identifier. |
| `schema_name` | `VARCHAR` | Optional schema name. |
| `schema_encoding` | `VARCHAR` | Optional schema encoding. |
| `schema_data` | `BINARY` | Original embedded schema bytes. |
| `data` | `BINARY` | Original serialized message bytes. |
| `decoded` | `VARCHAR` | The decoded message, as JSON. Null when the encoding isn't supported. |
| `payload` | `BINARY` | Binary payload extracted from the message, such as image bytes. |
| `payload_type` | `VARCHAR` | Type of the extracted payload, such as `jpeg`. |
| `decode_error` | `VARCHAR` | Why the message couldn't be decoded. Null otherwise. |
| `image` | `BINARY` | Camera image from the message, as encoded bytes. |
| `format` | `VARCHAR` | Image format, such as `jpeg`. |
| `width`, `height` | `INT` | Extracted image dimensions. |
| `size_bytes` | `BIGINT` | Size of the image bytes. |
| `image_error` | `VARCHAR` | Why the image couldn't be extracted. Null otherwise. |

## Filter by topic and time

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    log_time,
    topic,
    image,
    width,
    height
FROM read_mcap('hf://buckets/chowderai/chowder-demo/mcap/data/road-spray-car-following.mcap')
WHERE topic = '/camera/image'
AND log_time >= TIMESTAMP '2021-09-08 11:40:49 UTC'
AND log_time < TIMESTAMP '2021-09-08 11:40:51 UTC'
LIMIT 5;
```

Filters on `topic` and `log_time` return exact results. When a file has an index, Chowder skips the chunks that can't match. Files without an index are read from start to finish.

## Execution

* Chowder decodes messages only when the query selects `decoded`, `payload`, or an image column. Queries that select only metadata or `data` skip decoding.
* `count(*)` uses the file's index when it has one, without reading messages.

> [card] [Query robotics logs](https://docs.chowder.ai/guides/robotics-logs.md)
>
> Start from a public MCAP recording and inspect topics, encodings, and payloads.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.