Skip to main content

Module sql

Module sql 

Source
Expand description

pond_sql_query: read-only DataFusion SQL over the three Lance tables (sessions / messages / parts), registered as LanceTableProviders (behind plan-time views that rename id to message_id / session_id) on a fresh per-call SessionContext. Read-only is enforced in two layers - a single-SELECT pre-parse and sql_with_options with DDL/DML/statements all disabled - so no statement that mutates the corpus or touches the filesystem (INSERT/UPDATE/DELETE/CREATE/DROP/COPY/CREATE EXTERNAL TABLE/SET) can run. Results render inline (row-capped) or export to a parquet/ndjson file the caller fetches via the pond-sql-export:// resource (src/transport.rs).

Structs§

Tables
The Lance datasets a query references, fetched fresh per call so each query sees a current snapshot (the handle freshness gate runs on each Store::dataset). A field is None when the query never names that table - the caller skips opening it, avoiding the slow parts.lance open on the common messages-only query (spec.md#search). See mentions_table.

Enums§

Format
Export serialization format. Vector columns are excluded and JSON columns are decoded to text before encoding (see [displayable]).
Mode
How pond_sql_query returns results.
Outcome
Result of a successful run.
SqlError
Two error channels: Query is caller-fixable (parse/plan/exec/limits) and the tool surfaces it as an isError result so the model self-corrects; Infra is an internal failure surfaced as a protocol error.

Constants§

DEFAULT_INLINE_ROWS
Default inline row cap when the caller passes no limit.
MAX_INLINE_ROWS
Upper bound on the caller-supplied inline limit.

Functions§

mentions_table
Whether sql references the table named table. A DataFusion query can only reach a registered table by writing its name literally - no alias hides the base name - so this lowercase word-boundary scan never yields a false negative. At worst it matches the name inside a string or column literal and opens a table the query won’t touch: a cheap, safe false positive. Lets the caller open only the datasets a query needs.
run
Execute one read-only SQL query and return either a rendered table, a JSON payload, or encoded export bytes.