> ## 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_documents

> Read PDF documents as a SQL table, one row per page.

`read_documents` parses PDF files and returns one row per page. Each row has the page as Markdown in `content` and its layout regions in `blocks`.

See [Models](https://docs.chowder.ai/concepts/models.md) for the models Chowder uses to parse pages, including layout detection, table structure, and OCR.

## Signature

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

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

Supported extension: `.pdf`.

## Example

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    source,
    page_number,
    page_count,
    content -- Parsed PDF page in Markdown
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
WHERE page_number <= 3;
```

## Columns

| Column | Type | Description |
| - | - | - |
| `source` | `VARCHAR` | Input path or URI. |
| `page_number` | `BIGINT` | One-based page number. |
| `page_count` | `BIGINT` | Total pages in the document. |
| `content` | `VARCHAR` | Page content as Markdown, assembled from `blocks`. |
| `blocks` | `ARRAY<STRUCT>` | Ordered page blocks, each with `kind`, `content`, `bbox`, `has_ocr`, and `repeated_boilerplate`. |
| `has_table` | `BOOLEAN` | Whether the page contains a detected table. |
| `has_image` | `BOOLEAN` | Whether the page contains a detected picture. |
| `has_ocr` | `BOOLEAN` | Whether the page contains OCR-derived content. |
| `incomplete` | `BOOLEAN` | Whether the page comes from a document that failed to parse or was cut short by `LIMIT`. Incomplete rows aren't cached. |
| `metadata` | `STRUCT` | Page diagnostics: `routing`, `error`, `n_chars`, `elapsed_s`, and `cached`. |

`content` is rendered from `blocks`. Use `blocks` when you need individual layout regions, such as tables or headings, and their positions.

If a document cannot be opened, Chowder retains an incomplete row with null page ordinals and the failure in `metadata.error`. Files larger than `CHOWDER_MAX_FILE_MB` (500 MB by default) are skipped with a warning and produce no rows. A remote server can set its own limit. See [Configuration](https://docs.chowder.ai/reference/configuration.md).

## Expand pages into blocks

```chowder-sql theme={"theme":"css-variables","languages":{"custom":["/languages/chowder-sql.json"]}}
SELECT
    source,
    page_number,
    unnest(blocks) AS block -- Expand the page into one row per layout region
FROM read_documents('hf://buckets/chowderai/chowder-demo/pdf/data/att-management-discussion-and-analysis-2020.pdf')
WHERE page_number = 3;
```

## Execution

* Queries that select only `source`, `page_number`, or `page_count`, including `count(*)`, read the page count without parsing pages.
* Page predicates and `LIMIT` reduce parsing work.

> [card] [Document extraction with infer](https://docs.chowder.ai/guides/inference.md)
>
> Extract `BOOL`, `TEXT`, `ENUM`, `ARRAY`, or `STRUCT` values from `content`.

See [Caching](https://docs.chowder.ai/concepts/caching.md) for result reuse, cache validity, and cache controls.


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