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

# Parable Data Engine

> Query your Workspace's data with read-only SQL: Provider, Artifact, Parable, and Workspace pools, quality, and AI functions.

The **Parable Data Engine** is the read-only SQL surface over your
Workspace's data. It puts four **pools** on one SQL connection. Each pool is a
catalog that you address by name. [AI functions](https://developers.askparable.com/data/ai.md), such as
`ponder()` and `embed()`, run on the same connection.

[Connectors](https://developers.askparable.com/connectors/overview.md) and [Ingestion](https://developers.askparable.com/connectors/ingestion.md)
explain how a Provider connects and syncs. This section explains the tables
that a sync produces, and the pools beside them.

```mermaid theme={null}
flowchart LR
  C["Provider syncs"] --> PR["providers"]
  PR --> Q["providers_quality"]
  U["Published files"] --> A["artifacts"]
  P["Plots"] --> PA["parables"]
  M["Workspace settings"] --> W["workspace"]
```

| Pool | Address | What it holds |
| - | - | - |
| **[providers](https://developers.askparable.com/data/providers.md)** | `providers.{connector}.{table}` | Current data from each connected Provider. [Tap projection](https://developers.askparable.com/connectors/tap-projection.md) shows how a data stream becomes tables. |
| **[artifacts](https://developers.askparable.com/data/artifacts.md)** | `artifacts.{namespace}.{table}` | Files published as tables, and the data files of each Parable. |
| **[parables](https://developers.askparable.com/data/parables.md)** | `parables.{parable}.{plot}` | Stored Plot results, and views of the Plots that nothing stores. |
| **[workspace](https://developers.askparable.com/data/workspace.md)** | `workspace.{table}` | Live Workspace metadata: members, roles, Providers, Parables, and Plot runs. |

[Quality](https://developers.askparable.com/data/quality.md) is a companion catalog, `providers_quality`. It is
not a fifth data pool. It holds quality checks, statistical process control
(SPC), shape statistics, and health for Provider tables.

`providers_quarantine` is a second companion catalog. It holds the records
that a Provider sent and that failed validation. Its tables use the same
`{connector}.{table}` names as the `providers` pool.

References are fully qualified. There is no `USE` statement or
`search_path`. The Workspace that the request names selects the tables you
see. A catalog name never contains the Workspace slug.

## The catalog

The catalog lists the Workspace's tables across the pools. For each table, it
can report:

* **Shape**: the Arrow schema, the semantic type of each column, and row
  counts.
* **Freshness**: when Provider data last arrived, when a file was published,
  or when a Plot last completed. Workspace tables are current at query time.
* **Quality**: the latest checks and SPC results. Query their history in
  [Quality](https://developers.askparable.com/data/quality.md).
* **Lineage**: the Provider stream, file, or Plot that produces the table.

When the catalog omits a value, the value is not known yet.

Read the catalog over the Workspace API with a Parable token or an MCP token.
An MCP token works only while the Workspace allows external agents
([SQL over HTTP](https://developers.askparable.com/data/sql-over-http.md#before-you-start)). `PARABLE_API_TOKEN`
holds that token on this page. The Workspace API refuses a SQL token:

```bash theme={null}
curl "$PARABLE_API_URL/api/v2/catalog" \
  -H "Authorization: Bearer $PARABLE_API_TOKEN" \
  -H "X-Tenant: $PARABLE_WORKSPACE"
```

```json Response (shortened) theme={null}
{
  "data": {
    "tables": [
      {
        "catalog": "providers",
        "schemaName": "google",
        "logicalName": "users",
        "statsRowCount": 1240,
        "primaryKey": { "columns": ["id"] },
        "fields": [
          { "name": "primaryemail", "arrowType": "Utf8", "scalarRef": "Contact.Email", "system": false },
          { "name": "dt", "arrowType": "Utf8", "scalarRef": null, "system": true }
        ]
      }
    ]
  },
  "meta": { "requestId": "..." }
}
```

Other fields are not shown. `system: true` marks a column that Parable adds,
such as `dt` and the `_parable_*` [state columns](https://developers.askparable.com/data/providers.md#read-current-rows).
The app hides these columns behind **Show system columns**. You can still
select them in SQL. Flight SQL marks the same columns with the field metadata
`parable.annotation.system`.

`GET /api/v2/catalog/table-stats` returns the row count, size, latest
quality result, and freshness of each Provider table. The
[API Reference](https://developers.askparable.com/api-reference/overview.md) lists both operations. Both need the
`tenant.data.catalog` permission.

What the catalog shows depends on who asks:

* **Statistics follow your access.** When a Provider Policy or source
  permissions narrow or hide a table for you, the catalog withholds its row
  count and validation rates, because they describe rows you cannot read.
  The table and its columns are still listed. People with All data access see
  every statistic.
* **An agent sees its owner's pools.** With an MCP token, or through the
  Parable MCP server after an MCP host signs in, the catalog and table
  statistics list only the tables in the pools that the owner can query over
  SQL. A Parable token lists what its owner's session lists.

SQL tools read the same tables through standard Flight SQL metadata and
`information_schema`. To find the tables and columns that hold some kind of
data, call the `search_available_data` table function:

```sql theme={null}
SELECT table_ref, column_name, description
FROM search_available_data('which providers are connected')
ORDER BY score DESC, qualified_name
LIMIT 10
```

`search_available_data` searches the Provider and Workspace pools. It runs in
interactive queries only, so a Plot cannot call it. [Search](https://developers.askparable.com/data/search.md)
explains it, and `search_everything`, which finds Provider records by what
their text says.

A table can be in the catalog before it has rows. A table with no rows still
has a schema, so an empty result is not a missing table. To find out whether a
table has data, count its rows:

```sql theme={null}
SELECT COUNT(*) AS row_count
FROM providers.google.users
```

## Query the pools

The pools are queryable over **Arrow Flight SQL** at `sql.parable.work`, port
443, with TLS. ADBC and JDBC drivers work, and so do SQL tools such as
DBeaver and DataGrip.

Every call sends two values:

* `authorization: Bearer <token>`. Use a SQL token that a Workspace member
  creates in **Protection → Access Tokens**. A SQL token works only over SQL.
  The Workspace API refuses it.
* `x-tenant: <workspace-slug>`, such as `acme-corp`.

Your Workspace role decides which pools you can query:

| Role | Pools |
| - | - |
| Provider Pools Reader | `providers`, `providers_quarantine`, `providers_quality` |
| Data Access | Every pool |
| Workspace Administrator | Every pool |

No role reads the namespace of a Parable's files, `artifacts.parable_<parable>`,
outside that Parable. Only SQL in the Parable reads it
([Who reads a Parable's tables](https://developers.askparable.com/data/artifacts.md#who-reads-a-parables-tables)).

A query that names a pool your role does not reach fails with
`FROM or JOIN names a source this Workspace cannot read. Choose an available source, or ask a Workspace Administrator to check your data access.` (`QL-PL-002`).

### Rows you can read

Your role decides which pools you reach. Two Workspace controls then decide
which rows of a Provider table you read:

* **Provider Policies.** A Workspace administrator gives each role **All
  rows**, **Rows where** some conditions hold, **Hidden** (no rows), or
  **Source permissions** on a table, in **Protection → Provider Policies**.
* **Source permissions.** You read only the rows that you can open in the
  Provider itself, such as the files shared with you. They apply when a
  Provider Policy rule says so, or when the Workspace enforces them.
  [Source permissions](https://developers.askparable.com/connectors/source-permissions.md) explains how a Provider
  declares them.

A narrowed query is not an error. It returns fewer rows, or none. The
[Quality](https://developers.askparable.com/data/quality.md) tables of a narrowed table read as empty for you,
and the catalog withholds its statistics.

People who hold **All data access** (`tenant.data.unrestricted`), such as
Workspace Administrators, read every row past both controls. That covers
Flight SQL with a SQL token, SQL in the app, and the Refreshes they run.
Parable records each such read in the Workspace's audit events, with a hash of
the SQL. The [SQL over HTTP](https://developers.askparable.com/data/sql-over-http.md) operations are an
exception: Policies narrow them for everyone.

Two errors come from these controls:

| Code | Meaning |
| - | - |
| `QL-TN-009` | Source permissions decide who reads this table, and Parable cannot yet tell who may open its rows. For example, it has not computed the Provider's access after a new connection. Parable reads nothing. Try again after the next sync. |
| `QL-TN-007` | You read a Plot result that a Report run stored (a Refresh). It was stored with rows that a Provider Policy or source permissions keep from you, so you cannot open it. See [Parables](https://developers.askparable.com/data/parables.md#stored-results-and-your-access). |

[Provider Policies](https://docs.parable.work/protection/provider-policies)
explains each rule.

The examples below query the [providers](https://developers.askparable.com/data/providers.md) pool. To query
another pool, change the table to `artifacts.{namespace}.{table}`,
`parables.{parable}.{plot}`, `workspace.{table}`, or
`providers_quality.summary.{table}`. Set `PARABLE_SQL_TOKEN` to your SQL
token and `PARABLE_WORKSPACE` to your Workspace slug first. Keep the SQL token
apart from `PARABLE_API_TOKEN`, which the Workspace API examples use.

```python query.py theme={null}
import os

import adbc_driver_flightsql.dbapi
from adbc_driver_flightsql import DatabaseOptions

with adbc_driver_flightsql.dbapi.connect(
    "grpc+tls://sql.parable.work:443",
    db_kwargs={
        DatabaseOptions.AUTHORIZATION_HEADER.value:
            f"Bearer {os.environ['PARABLE_SQL_TOKEN']}",
        f"{DatabaseOptions.RPC_CALL_HEADER_PREFIX.value}x-tenant":
            os.environ["PARABLE_WORKSPACE"],
    },
) as conn:
    with conn.cursor() as cur:
        cur.execute(
            """
            SELECT
              id,
              primaryemail,
              orgunitpath,
              isadmin,
              lastlogintime
            FROM providers.google.users
            WHERE suspended = false
            LIMIT 10
            """
        )
        print(cur.fetch_arrow_table())
```

```go query.go theme={null}
import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/apache/arrow-go/v18/arrow/flight/flightsql"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials"
	"google.golang.org/grpc/metadata"
)

ctx := metadata.AppendToOutgoingContext(
	context.Background(),
	"authorization", "Bearer "+os.Getenv("PARABLE_SQL_TOKEN"),
	"x-tenant", os.Getenv("PARABLE_WORKSPACE"),
)

client, err := flightsql.NewClient(
	"sql.parable.work:443",
	nil,
	nil,
	grpc.WithTransportCredentials(credentials.NewTLS(nil)),
)
if err != nil {
	log.Fatal(err)
}
defer client.Close()

info, err := client.Execute(ctx, `
SELECT
  id,
  primaryemail,
  orgunitpath,
  isadmin,
  lastlogintime
FROM providers.google.users
WHERE suspended = false
LIMIT 10
`)
if err != nil {
	log.Fatal(err)
}

reader, err := client.DoGet(ctx, info.Endpoint[0].Ticket)
if err != nil {
	log.Fatal(err)
}
defer reader.Release()

for reader.Next() {
	fmt.Println(reader.Record())
}
if err := reader.Err(); err != nil {
	log.Fatal(err)
}
```

```rust query.rs theme={null}
use arrow_flight::sql::client::FlightSqlServiceClient;
use futures::TryStreamExt;
use tonic::transport::Channel;

let token = std::env::var("PARABLE_SQL_TOKEN")?;
let workspace = std::env::var("PARABLE_WORKSPACE")?;
let channel = Channel::from_static("https://sql.parable.work")
    .connect()
    .await?;
let mut client = FlightSqlServiceClient::new(channel);
client.set_header("authorization", format!("Bearer {token}"));
client.set_header("x-tenant", workspace);

let info = client
    .execute(
        r#"
        SELECT
          id,
          primaryemail,
          orgunitpath,
          isadmin,
          lastlogintime
        FROM providers.google.users
        WHERE suspended = false
        LIMIT 10
        "#
        .to_string(),
        None,
    )
    .await?;
let ticket = info.endpoint[0].ticket.clone().expect("ticket");
let mut stream = client.do_get(ticket.into()).await?;
while let Some(batch) = stream.try_next().await? {
    println!("{batch:?}");
}
```

There is no published TypeScript Flight SQL client.

A query can run for up to one hour and return up to 2,000,000 rows. A query
past a limit fails. Parable does not truncate the result.
[Flight SQL](https://docs.parable.work/protocols/sql/flight-sql) lists every
limit and error code.

> [!NOTE]
>
> [Query Provider Pools with SQL](https://docs.parable.work/protocols/sql/query-provider-pools)
> shows how to get a role, create a SQL token, and connect DBeaver or Python,
> step by step.

## See the plan of a query

Put `EXPLAIN` before a query to see how Parable will run it. Parable plans
the query exactly as it would run it, and runs nothing. No AI function is
called.

```sql theme={null}
EXPLAIN
SELECT orgunitpath, COUNT(*) AS users
FROM providers.google.users
WHERE suspended = false
GROUP BY orgunitpath
```

The result has two rows, with the columns `plan_type` and `plan`:

| `plan_type` | `plan` |
| - | - |
| `logical_plan` | The optimized plan of your SQL: its tables, columns, filters, joins, aggregates, and sorts. |
| `physical_plan` | The operators that run, each with its partition count and safe details. A filter shows no condition, so a Policy's condition never appears. |

The plan holds no cost figures. To see how much data a query reads and how
many AI calls it can make, use the
[dry run](https://developers.askparable.com/data/sql-over-http.md#check-a-query-before-you-run-it).

Only plain `EXPLAIN` followed by one query works:

| Form | Error code |
| - | - |
| `EXPLAIN ANALYZE`, which would run the query and its AI calls | `QL-SQ-008` |
| `EXPLAIN VERBOSE`, `EXPLAIN FORMAT ...`, `DESCRIBE`, and other forms | `QL-SQ-009` |
| `EXPLAIN` of a write, or of more than one statement | `QL-SQ-003` |

`EXPLAIN` works over Flight SQL and [SQL over HTTP](https://developers.askparable.com/data/sql-over-http.md). A
Plot's SQL cannot hold it.

## More ways to read data

> [card] [SQL over HTTP](https://developers.askparable.com/data/sql-over-http.md)
>
> Run read-only SQL over the Provider Pools with JSON requests, without a
> Flight SQL client. Check a query's cost before you run it.

> [card] [Search](https://developers.askparable.com/data/search.md)
>
> Find tables by what they hold, and Provider records by what their text
> says.

> [card] [Build a Lab](https://developers.askparable.com/data/labs.md)
>
> Run your own React app inside a Parable, and read Workspace data from it.

> [card] [AI functions](https://developers.askparable.com/data/ai.md)
>
> Call models from SQL with `ponder()`, `embed()`, and the Jev functions.


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