> For the complete documentation index, see [llms.txt](https://docs-lunar.earthly.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-lunar.earthly.dev/sql-api/views/prs.md).

# prs

Schema reference for the prs SQL view — pull request and merge request metadata including author, status, and latest commit details.

```
prs
```

The `prs` view provides information about component pull requests. The information in this view is largely mirrored from your Git platform, and is provided for convenience.

GitLab merge requests appear in this view alongside GitHub pull requests — a merge request's number is recorded in the same column as a pull request's.

A pull request is listed under the components it was processed for. In a monorepo with several components defined on one repository, a pull request that only touches `services/api/` appears under the `services/api` component and not under its siblings, so filtering by `component_id` returns that component's pull requests rather than the repository's. Lunar decides this when it receives the pull request's webhook, by matching the changed files against each component's `paths`, and when a run is explicitly targeted at a component on one of the pull request's commits; once the pull request has been processed for at least one component of the repository, it does not appear under the components it was not processed for.

A pull request processed for no component of its repository is listed under every component of the repository, as there is nothing to narrow it by. That is the case for a pull request from before Lunar started receiving the repository's webhooks, for one whose webhook delivery did not complete, and also for one whose changed files matched no component's `paths` at all — a monorepo pull request that only edits root-level files such as `.github/` or a top-level README. Lunar does not record a "matched nothing" outcome separately from a delivery that failed before matching, so the two cannot be told apart and neither narrows the pull request.

## Schema

| Column                    | Type        | Description                                                                 |
| ------------------------- | ----------- | --------------------------------------------------------------------------- |
| `component_id`            | `TEXT`      | The identifier for the component - e.g. `github.com/foo/bar/buz`            |
| `pr`                      | `BIGINT`    | The pull request number                                                     |
| `pr_opened_at`            | `TIMESTAMP` | The UTC timestamp when the pull request was opened                          |
| `pr_status`               | `TEXT`      | The status of the pull request. Can be one of `open`, `closed`, or `merged` |
| `title`                   | `TEXT`      | The title of the pull request                                               |
| `author_name`             | `TEXT`      | The name of the author of the pull request                                  |
| `author_email`            | `TEXT`      | The email of the author of the pull request                                 |
| `latest_git_sha`          | `TEXT`      | The latest Git commit SHA of the pull request                               |
| `latest_commit_timestamp` | `TIMESTAMP` | The "committed at" UTC timestamp of the latest commit in the pull request   |
| `latest_committer_name`   | `TEXT`      | The name of the committer of the latest commit in the pull request          |
| `latest_committer_email`  | `TEXT`      | The email of the committer of the latest commit in the pull request         |

## Usage example

Retrieve PR information for all the PRs that have failing checks in a component.

```sql
WITH failing_prs AS (
  SELECT DISTINCT pr
  FROM checks_latest
  WHERE component_id = 'github.com/foo/bar/buz'
    AND pr IS NOT NULL
    AND status = 'fail'
)
SELECT *
FROM prs
WHERE component_id = 'github.com/foo/bar/buz'
  AND pr IN (SELECT pr FROM failing_prs);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs-lunar.earthly.dev/sql-api/views/prs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
