From 9e3af3625d03e90506fb29bf9b48dec162b17dc0 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Fri, 27 Nov 2026 19:02:17 -0800 Subject: [PATCH] docs(sql): document text and JSON descriptions Apply the reviewed DESCRIBE TEXT and JSON contract. --- docs/web/basics/sql.mdx | 4 + docs/web/docs.json | 1 + docs/web/sql/ddl/database.mdx | 8 +- docs/web/sql/ddl/function.mdx | 6 +- docs/web/sql/ddl/job.mdx | 29 ++--- docs/web/sql/ddl/materialized-view.mdx | 12 +++ docs/web/sql/ddl/namespace.mdx | 9 +- docs/web/sql/ddl/secret.mdx | 9 +- docs/web/sql/ddl/storage-integration.mdx | 10 +- docs/web/sql/ddl/table.mdx | 8 +- docs/web/sql/ddl/view.mdx | 5 +- docs/web/sql/describe.mdx | 132 +++++++++++++++++++++++ docs/web/sql/index.mdx | 9 +- 13 files changed, 198 insertions(+), 44 deletions(-) create mode 100644 docs/web/sql/describe.mdx diff --git a/docs/web/basics/sql.mdx b/docs/web/basics/sql.mdx index 42615191f..8884b4827 100644 --- a/docs/web/basics/sql.mdx +++ b/docs/web/basics/sql.mdx @@ -154,6 +154,10 @@ results, or to track and cancel a running query, see [Read and manage results](#results). To submit a query and check its status separately, use `execute_query_async()`. +To inspect an object, use `DESCRIBE TABLE frames` for readable TEXT or +`DESCRIBE TABLE frames FORMAT JSON` for application metadata. Both return one +`description` document; see [DESCRIBE formats](/sql/describe). + ## Parameters in SQL queries {#parameters} Pass a `parameters` argument to bind values into a query, instead of diff --git a/docs/web/docs.json b/docs/web/docs.json index f2cd5ffa6..23bdcc5b2 100644 --- a/docs/web/docs.json +++ b/docs/web/docs.json @@ -549,6 +549,7 @@ "group": "SQL Reference", "pages": [ "sql/index", + "sql/describe", "sql/pagination", "sql/data-types", { diff --git a/docs/web/sql/ddl/database.mdx b/docs/web/sql/ddl/database.mdx index f84d4cfb9..07b55a882 100644 --- a/docs/web/sql/ddl/database.mdx +++ b/docs/web/sql/ddl/database.mdx @@ -43,14 +43,14 @@ database. ```sql SQL icon="database" -DESCRIBE DATABASE analytics +DESCRIBE DATABASE analytics [FORMAT TEXT | JSON] DESC DATABASE "team/search" ``` -Requires `USAGE` on the database. Returns one row with `name` and -`properties`. Properties are the catalog's metadata encoded as a JSON -object; a database without metadata returns `{}`, and a database mid +Requires `USAGE` on the database. Returns one `description` document with +`name` and native `properties`, as readable TEXT (the default) or JSON. See +[DESCRIBE formats](/sql/describe). Properties contain the catalog's metadata; a database without metadata returns `{}`, and a database mid `CASCADE` drop reports a transient property marking it as dropping. A missing database is an error. `DESCRIBE DATABASE system` returns empty properties and requires system `USAGE`. diff --git a/docs/web/sql/ddl/function.mdx b/docs/web/sql/ddl/function.mdx index 643ee36a2..1a8f573d6 100644 --- a/docs/web/sql/ddl/function.mdx +++ b/docs/web/sql/ddl/function.mdx @@ -103,11 +103,13 @@ registration handle has type `query` and uses the SQL query UUID as its single ## DESCRIBE and ALTER FUNCTION {#describe-alter} ```sql -DESCRIBE FUNCTION embed WITH (version = '1', include_source = true) +DESCRIBE FUNCTION embed WITH (version = '1', include_source = true) FORMAT JSON DESCRIBE FUNCTION embed ``` -DESCRIBE returns one `definition` JSON column for the exact version. When +DESCRIBE returns one `description` document for the exact version. TEXT is the +default; `FORMAT JSON` returns the complete Function-version object, including +its signature and runtime. See [DESCRIBE formats](/sql/describe). When `version` is omitted, it resolves and returns the latest currently visible immutable revision. `include_source` defaults to false; source-inclusive reads report an omission diff --git a/docs/web/sql/ddl/job.mdx b/docs/web/sql/ddl/job.mdx index 914d2944b..49a5a4179 100644 --- a/docs/web/sql/ddl/job.mdx +++ b/docs/web/sql/ddl/job.mdx @@ -79,28 +79,19 @@ allowlisted diagnostics; raw parent payloads are excluded. ```sql SQL icon="database" -DESCRIBE JOB '' [FORMAT TEXT | TABLE | JSON] -DESC JOB '' [FORMAT TEXT | TABLE | JSON] +DESCRIBE JOB '' [FORMAT TEXT | JSON] +DESC JOB '' [FORMAT TEXT | JSON] ``` -`TEXT` is the default and shows a finished root job's timing profile; -`TABLE` returns typed phase/step rows. These formats have no profile rows -while a job runs. - -On compatible deployments, `JSON` returns one document in the `profile` -column with `job_id`, `job_type`, `job_state`, reported `progress`, and the -successful operation's `result`, alongside any timing profile. It works -while the job runs, when `result` is null. Compaction counters describe -committed work only in the result; progress counters describe observed -execution work. Data prewarm results identify the pinned table version and -reported executor work. Unavailable measurements remain absent or null. - -```sql -DESCRIBE JOB '' FORMAT JSON; -``` - -Older deployments return only the timing profile. +Both formats return one `description` document with job identity, type, state, +reported progress, successful result and any timing profile. TEXT is the +default. JSON keeps nested profile/progress/result values native; a running +job's result is null. Unknown measurements remain absent or null. Compaction +progress describes observed work, while its result describes committed work. +Data prewarm results include the pinned table version and executor work. +See [DESCRIBE formats](/sql/describe). Detailed retained timelines remain +available through the REST/SDK export API and are not loaded by DESCRIBE. ## SHOW ERRORS {#errors} diff --git a/docs/web/sql/ddl/materialized-view.mdx b/docs/web/sql/ddl/materialized-view.mdx index 271885fec..9b68d8b8c 100644 --- a/docs/web/sql/ddl/materialized-view.mdx +++ b/docs/web/sql/ddl/materialized-view.mdx @@ -68,6 +68,18 @@ automatic execution needs the same server-side switch enabled. Omitting `WITH` leaves automatic refresh at the server's default. */} +## DESCRIBE MATERIALIZED VIEW {#describe} + +```sql +DESCRIBE MATERIALIZED VIEW document_features [FORMAT TEXT | JSON]; +``` + +Returns one `description` document containing the defining query, source +version, refresh policy, observed refresh state and available timestamps or +dependency diagnostics. TEXT is the default; JSON retains native numbers, +booleans and nulls, with RFC3339 timestamp strings. See +[DESCRIBE formats](/sql/describe). + ## SHOW MATERIALIZED VIEWS {#show} ```sql diff --git a/docs/web/sql/ddl/namespace.mdx b/docs/web/sql/ddl/namespace.mdx index 14391ac18..ad1b93cf3 100644 --- a/docs/web/sql/ddl/namespace.mdx +++ b/docs/web/sql/ddl/namespace.mdx @@ -110,14 +110,15 @@ The result has `operation`, `name`, and `status` columns, with operation ```sql SQL icon="database" -DESCRIBE SCHEMA analytics.`team$features` -DESCRIBE NAMESPACE features IN analytics.team +DESCRIBE SCHEMA analytics.`team$features` [FORMAT TEXT | JSON] +DESCRIBE NAMESPACE features IN analytics.team [FORMAT TEXT | JSON] DESC NAMESPACE features IN team ``` -Returns one row with `name` (the complete `$`-joined schema path) and -`properties` (a JSON object). An unannotated namespace returns `{}`. A +Returns one `description` document with `name` (the complete `$`-joined schema +path) and native `properties`. TEXT is the default; `FORMAT JSON` selects a +structured document. See [DESCRIBE formats](/sql/describe). An unannotated namespace returns `{}`. A missing namespace is an error. `DESC` is an alias for `DESCRIBE`. diff --git a/docs/web/sql/ddl/secret.mdx b/docs/web/sql/ddl/secret.mdx index 15039c6c7..595ae6714 100644 --- a/docs/web/sql/ddl/secret.mdx +++ b/docs/web/sql/ddl/secret.mdx @@ -122,20 +122,21 @@ a short or empty page can still carry a continuation. See ```sql SQL icon="database" -DESCRIBE SECRET platform.`model-api-key` +DESCRIBE SECRET platform.`model-api-key` [FORMAT TEXT | JSON] DESC SECRET api_key ``` -Returns one row: +Returns one `description` document as TEXT (default) or JSON. Its fields are: -| Column | Type | Meaning | +| Field | JSON type | Meaning | | --- | --- | --- | | `name` | string | The Secret's name | | `created_at_millis` | int64 | When it was created, in milliseconds since the Unix epoch | | `updated_at_millis` | int64 | When its value was last set. Watch this change to confirm a rotation landed. | -| `history` | list of struct `{generation: uint64, at_millis: int64}` | Creation and each rotation since, oldest first, up to the most recent 100 | +| `history` | array of `{generation: number, at_millis: number}` | Creation and each rotation since, oldest first, up to the most recent 100 | +Secret values are never returned. See [DESCRIBE formats](/sql/describe). A missing Secret is an error. Requires `USAGE` on the Secret. ## GRANT and REVOKE {#grant} diff --git a/docs/web/sql/ddl/storage-integration.mdx b/docs/web/sql/ddl/storage-integration.mdx index 9e22970ec..5ea315cf0 100644 --- a/docs/web/sql/ddl/storage-integration.mdx +++ b/docs/web/sql/ddl/storage-integration.mdx @@ -183,17 +183,19 @@ worker finishes. See [`CREATE TABLE`](/sql/ddl/table#create) for ```sql SQL icon="database" -DESCRIBE STORAGE INTEGRATION raw +DESCRIBE STORAGE INTEGRATION raw [FORMAT TEXT | JSON] DESC STORAGE INTEGRATION platform.hub ``` -Returns one row with every column `CREATE` returns: the provider, prefix, -the Secret references and plain-string options that apply to its +Returns one `description` document as TEXT (default) or JSON, containing the +provider, prefix, native Secret references and options that apply to its provider (the rest are null), `created_at_millis`, `access_verified`, and -- for an `STORAGE_AWS_ROLE_ARN` integration -- the generated AWS policy documents from [above](#trust). No call ever returns a Secret's value, -only the reference naming it. +only the reference naming it. JSON keeps namespace paths, Secret references +and policy documents native. See [DESCRIBE formats](/sql/describe). CREATE +retains its own result schema. ## SHOW STORAGE INTEGRATIONS {#show} diff --git a/docs/web/sql/ddl/table.mdx b/docs/web/sql/ddl/table.mdx index e2b50168a..06134702b 100644 --- a/docs/web/sql/ddl/table.mdx +++ b/docs/web/sql/ddl/table.mdx @@ -29,12 +29,14 @@ A table inside a [namespace](/sql/ddl/namespace) is written with its ```sql SQL icon="database" -DESCRIBE documents +DESCRIBE TABLE documents [FORMAT TEXT | JSON] ``` -The table's columns and types, without a plan. The SQL counterpart of -`table.schema`. +Returns one complete `description` document, with readable TEXT as the default. +JSON includes the resolved name, database and namespace path, table description +and a `columns` array with names, displayed types, boolean nullability and +column descriptions. See [DESCRIBE formats](/sql/describe). ## ALTER TABLE {#alter} diff --git a/docs/web/sql/ddl/view.mdx b/docs/web/sql/ddl/view.mdx index 38fd37e30..c03004d46 100644 --- a/docs/web/sql/ddl/view.mdx +++ b/docs/web/sql/ddl/view.mdx @@ -49,7 +49,10 @@ The statement returns one row with UTF-8 `name`, `query`, and `schema` columns. defining database and namespace. The root namespace is `public`; nested namespace components are separated by `$`. -`DESCRIBE VIEW "recent_matches"` returns the same metadata shape. Anything the +`DESCRIBE VIEW "recent_matches" [FORMAT TEXT | JSON]` returns those fields in +one `description` document. TEXT is the default; JSON keeps the Arrow schema +native. CREATE retains its typed result columns. See [DESCRIBE formats](/sql/describe). +Anything the [dialect](/sql/dql/functions) supports can define one: joins, predicates, aggregates, window functions. diff --git a/docs/web/sql/describe.mdx b/docs/web/sql/describe.mdx new file mode 100644 index 000000000..de7c08f7b --- /dev/null +++ b/docs/web/sql/describe.mdx @@ -0,0 +1,132 @@ +--- +title: "DESCRIBE" +sidebarTitle: "DESCRIBE formats" +description: "Read complete object descriptions as readable TEXT or structured JSON." +icon: circle-info +keywords: ["describe", "desc", "format text", "format json", "sql metadata"] +availability: + embedded: unavailable + enterprise: available +--- + +`DESCRIBE` inspects one object. `TEXT` is the default for reading in a SQL +shell; choose `FORMAT JSON` when application code needs individual fields. +`DESC` is an alias for `DESCRIBE`. + +## Syntax {#syntax} + +```sql +DESCRIBE DATABASE analytics [FORMAT TEXT | JSON]; +DESCRIBE SCHEMA analytics.`team$features` [FORMAT TEXT | JSON]; +DESCRIBE NAMESPACE features [IN analytics.team] [FORMAT TEXT | JSON]; +DESCRIBE TABLE documents [FORMAT TEXT | JSON]; +DESCRIBE VIEW recent_documents [FORMAT TEXT | JSON]; +DESCRIBE MATERIALIZED VIEW document_features [FORMAT TEXT | JSON]; +DESCRIBE FUNCTION embed [WITH (version = '1', include_source = true)] [FORMAT TEXT | JSON]; +DESCRIBE SECRET platform.api_key [FORMAT TEXT | JSON]; +DESCRIBE STORAGE INTEGRATION raw [FORMAT TEXT | JSON]; +DESCRIBE COMPUTE INTEGRATION batch [FORMAT TEXT | JSON]; +DESCRIBE CLUSTER main [FORMAT TEXT | JSON]; +DESCRIBE JOB '' [FORMAT TEXT | JSON]; +``` + +Square brackets mark optional syntax. Use the same object names and namespace +resolution as the corresponding object commands. The format changes only the +representation: authorization, object lookup and metadata visibility are the +same in both formats. Missing objects are errors. Deployment configuration +still determines whether a particular object type is available. + +Only `TEXT` and `JSON` are accepted. `FORMAT` belongs to the SQL statement; +it is separate from a client's table, CSV or JSON display setting. + +## Result contract {#result} + +Both formats return **one SQL row and one non-null UTF8 column named +`description`**. The value contains the entire description: + +- `TEXT`: a readable document with labeled fields and indented nested sections. +- `JSON`: one JSON object, with nested arrays, objects, booleans and numbers. + Nested fields are not additional JSON-encoded strings. + +At the Arrow Flight SQL layer, the complete document is still a UTF8 value. +It is not a set of separate SQL columns or an Arrow struct. Parse the JSON +value once to access its nested fields. The Arrow schema metadata key +`lancedb.describe.format` identifies the selected format as `text` or `json`. +JSON object field order is not part of the contract. + +`SHOW` statements keep their ordinary listing schemas and pagination. Use +`SHOW` to find object names and `DESCRIBE` to inspect one object. Mutation +results, such as `CREATE VIEW` or `ALTER FUNCTION`, retain their own schemas. +The job-description aliases `SHOW JOB ''` and `SHOW JOB SUMMARY ''` +use the same description contract as `DESCRIBE JOB`. + +## Complete example {#example} + +For a database named `analytics` whose only catalog property is +`owner=research`, these statements describe the same object: + +```sql +DESCRIBE DATABASE analytics; +DESCRIBE DATABASE analytics FORMAT TEXT; +``` + +The complete `description` value in either result is: + +```text +Database +name: analytics +properties: + owner: research +``` + +```sql +DESCRIBE DATABASE analytics FORMAT JSON; +``` + +The complete JSON `description` value is shown below, pretty-printed for +readability. The result still has one row and one column. + +```json +{ + "name": "analytics", + "properties": { + "owner": "research" + } +} +``` + +With an [Enterprise SQL connection](/basics/sql#sql-from-python), application +code explicitly requests JSON: + +```python +import json + +rows = db.execute_query( + "DESCRIBE DATABASE analytics FORMAT JSON" +).read_all().to_pylist() +metadata = json.loads(rows[0]["description"]) +print(metadata["properties"]["owner"]) +``` + +## Object contents {#contents} + +| Object | Description document | +| --- | --- | +| [Database](/sql/ddl/database#describe) | Name and native `properties` object. | +| [Schema / Namespace](/sql/ddl/namespace#describe) | Resolved schema name and native `properties` object. | +| [Table](/sql/ddl/table#describe) | Resolved name, database, namespace path, table description and `columns` array. Each column includes its name, displayed data type, boolean nullability and description. | +| [View](/sql/ddl/view) | Name, stored query and native Arrow schema document, including defining-context metadata. | +| [Materialized view](/sql/ddl/materialized-view#describe) | Name, query, source version, refresh policy and observed refresh state, timestamps and dependency diagnostics. | +| [Function](/sql/ddl/function#describe-alter) | The complete immutable Function-version document, including signature, runtime and available provenance. Version selection and `include_source` are explicit options. | +| [Secret](/sql/ddl/secret#describe) | Name, creation/update times and bounded generation history. Secret values are never returned. | +| [Storage Integration](/sql/ddl/storage-integration#describe) | Provider, prefix, configuration, native policy documents and Secret references. Credential values are never returned. | +| Compute Integration | Provider, configuration, namespace and native Secret references; numeric scheduling settings stay numeric. Private credential pins and values are excluded. | +| Cluster | Identity, state, observed component details and available resource specifications; temporary clusters also expose idle timeout and lifecycle metadata. | +| [Job](/sql/ddl/job#describe) | Identity, type, state, reported progress, successful result and any timing profile. Unknown measurements stay absent or null; a running job has a null result. | + +JSON uses `null` for unavailable nullable metadata and keeps known zero values +as zero. Catalog properties may be empty objects; empty collections remain +arrays or objects. Materialized-view timestamp values use RFC3339 strings; +fields explicitly named `*_millis` keep their numeric millisecond units. +Describing a job does not fetch its full retained trace recording; use the +REST/SDK timeline export API for that recording. diff --git a/docs/web/sql/index.mdx b/docs/web/sql/index.mdx index 1d779ea1f..11d8af2ca 100644 --- a/docs/web/sql/index.mdx +++ b/docs/web/sql/index.mdx @@ -43,6 +43,9 @@ and DDL/DML pages below. Reach for the SDKs instead for table-management operations that have no SQL form, such as a merge insert. See [What SQL cannot do](#cannot). +Use [DESCRIBE formats](/sql/describe) for readable TEXT (the default) or a +complete JSON metadata document. SHOW listings keep their normal schemas. + ## Reference {#reference} ### DDL, by object {#ddl} @@ -52,12 +55,12 @@ operations that have no SQL form, such as a merge insert. See | [Database](/sql/ddl/database) | `CREATE`, `DESCRIBE`, `SHOW`, `ATTACH`, `DROP DATABASE` | | [Namespace](/sql/ddl/namespace) | `CREATE`, `ALTER`, `DESCRIBE`, `SHOW`, `DROP SCHEMA`/`NAMESPACE` | | [Table](/sql/ddl/table) | `CREATE`, `DESCRIBE`, `ALTER`, `CLONE`, `DROP TABLE` | -| [View](/sql/ddl/view) | `CREATE VIEW`, `DROP VIEW` | -| [Materialized view](/sql/ddl/materialized-view) | `CREATE MATERIALIZED VIEW`, `SHOW MATERIALIZED VIEWS` | +| [View](/sql/ddl/view) | `CREATE`, `DESCRIBE`, `SHOW`, `DROP VIEW` | +| [Materialized view](/sql/ddl/materialized-view) | `CREATE`, `DESCRIBE`, `SHOW MATERIALIZED VIEWS` | | [Secret](/sql/ddl/secret) | `CREATE`, `ALTER`, `DESCRIBE`, `SHOW`, `DROP SECRET` | | [Storage Integration](/sql/ddl/storage-integration) | `CREATE`, `DESCRIBE`, `SHOW`, `DROP STORAGE INTEGRATION` | | [Index](/sql/ddl/index) | `CREATE INDEX`, `DROP INDEX` | -| [Function](/sql/ddl/function) | `CREATE FUNCTION`, `SHOW FUNCTIONS`, `DROP FUNCTION` | +| [Function](/sql/ddl/function) | `CREATE`, `DESCRIBE`, `SHOW`, `DROP FUNCTION` | | [Job](/sql/ddl/job) | `SHOW JOBS`, `SHOW JOB EVENTS`, `DESCRIBE JOB`, `SHOW ERRORS`, `PAUSE`/`RESUME`/`CANCEL JOB` | ### DML {#dml}