Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions airbyte/_direct_connectors/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class AgentReadAction(str, Enum):
"""Connector actions that only read data.

The `search` action is the connector's native API search, parallel to `get` and `list`.
The `sql_select` action runs one read-only SQL statement (or `SHOW TABLES`) on the query
engine behind a destination connector. Pass `sql` and `sql_dialect` (and optionally
The `sql_select` action runs one read-only SQL statement on the query engine behind a
destination connector: a `SELECT`/`WITH` query or the `SHOW TABLES`, `SHOW DATABASES`,
or `DESCRIBE TABLE <table>` macro. Pass `sql` and `sql_dialect` (and optionally
`dry_run`) in `api_args`; `entity_type` is ignored for this action.

The `download` action is deliberately absent even though it reads: it returns a binary
Expand Down
5 changes: 4 additions & 1 deletion airbyte/cloud/connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,10 @@ def execute_sql_query(
cursor: str | None = None,
dry_run: bool = False,
) -> ExternalApiExecuteResult:
"""Run a read-only SQL `SELECT` (or `SHOW TABLES`) through SQL passthrough.
"""Run a read-only SQL statement through SQL passthrough.

Accepted statements are a single `SELECT`/`WITH` query or the `SHOW TABLES`,
`SHOW DATABASES`, or `DESCRIBE TABLE <table>` macro.

`sql_dialect` defaults to the dialect registered for this connector's definition.
`dry_run=True` validates the statement and returns the result columns without
Expand Down
19 changes: 13 additions & 6 deletions airbyte/mcp/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,12 @@ def execute_external_sql_query(
],
sql: Annotated[
str,
Field(description="The read-only SQL statement to run, for example `SHOW TABLES`."),
Field(
description=(
"The read-only SQL statement to run: a `SELECT`/`WITH` query or the "
"`SHOW TABLES`, `SHOW DATABASES`, or `DESCRIBE TABLE <table>` macro."
)
),
],
sql_dialect: Annotated[
str | None,
Expand Down Expand Up @@ -1869,12 +1874,14 @@ def execute_external_sql_query(

Only SQL-passthrough destinations (Snowflake/BigQuery) support this tool.

Run `SHOW TABLES` first to discover tables; `sql_dialect` defaults to the
destination's registered dialect. Use `dry_run=True` with
`SELECT * FROM <table> LIMIT 1` to discover a table's columns.
Run `SHOW TABLES` first to discover tables and `SHOW DATABASES` to see the
databases the destination is scoped to; `sql_dialect` defaults to the
destination's registered dialect. Use `DESCRIBE TABLE <table>` to return a
table's columns without reading rows.

`SHOW TABLES` is the only non-`SELECT` statement accepted and takes no
`LIMIT`; add a `LIMIT` to every `SELECT`. On Snowflake prefer unquoted
Accepted statements are a single `SELECT`/`WITH` query plus the `SHOW TABLES`,
`SHOW DATABASES`, and `DESCRIBE TABLE <table>` macros. The `SHOW` macros take
no `LIMIT`; add a `LIMIT` to every `SELECT`. On Snowflake prefer unquoted
identifiers: double-quoting makes them case-sensitive.
"""
connector = _get_cloud_workspace(ctx, workspace_id).get_connector(connector_id)
Expand Down
Loading