mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-28 13:33:59 +00:00
docs(sql): document text and JSON descriptions
Apply the reviewed DESCRIBE TEXT and JSON contract.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -549,6 +549,7 @@
|
||||
"group": "SQL Reference",
|
||||
"pages": [
|
||||
"sql/index",
|
||||
"sql/describe",
|
||||
"sql/pagination",
|
||||
"sql/data-types",
|
||||
{
|
||||
|
||||
@@ -43,14 +43,14 @@ database.
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
DESCRIBE DATABASE analytics
|
||||
DESCRIBE DATABASE analytics [FORMAT TEXT | JSON]
|
||||
DESC DATABASE "team/search"
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
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`.
|
||||
|
||||
@@ -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
|
||||
|
||||
+10
-19
@@ -79,28 +79,19 @@ allowlisted diagnostics; raw parent payloads are excluded.
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
DESCRIBE JOB '<job_id>' [FORMAT TEXT | TABLE | JSON]
|
||||
DESC JOB '<job_id>' [FORMAT TEXT | TABLE | JSON]
|
||||
DESCRIBE JOB '<job_id>' [FORMAT TEXT | JSON]
|
||||
DESC JOB '<job_id>' [FORMAT TEXT | JSON]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
`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 '<job_id>' 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}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -110,14 +110,15 @@ The result has `operation`, `name`, and `status` columns, with operation
|
||||
|
||||
<CodeGroup>
|
||||
```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
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
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`.
|
||||
|
||||
<Note>
|
||||
|
||||
@@ -122,20 +122,21 @@ a short or empty page can still carry a continuation. See
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
DESCRIBE SECRET platform.`model-api-key`
|
||||
DESCRIBE SECRET platform.`model-api-key` [FORMAT TEXT | JSON]
|
||||
DESC SECRET api_key
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
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}
|
||||
|
||||
@@ -183,17 +183,19 @@ worker finishes. See [`CREATE TABLE`](/sql/ddl/table#create) for
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
DESCRIBE STORAGE INTEGRATION raw
|
||||
DESCRIBE STORAGE INTEGRATION raw [FORMAT TEXT | JSON]
|
||||
DESC STORAGE INTEGRATION platform.hub
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
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}
|
||||
|
||||
|
||||
@@ -29,12 +29,14 @@ A table inside a [namespace](/sql/ddl/namespace) is written with its
|
||||
|
||||
<CodeGroup>
|
||||
```sql SQL icon="database"
|
||||
DESCRIBE documents
|
||||
DESCRIBE TABLE documents [FORMAT TEXT | JSON]
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
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}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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 '<job_id>' [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 '<id>'` and `SHOW JOB SUMMARY '<id>'`
|
||||
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.
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user