SQL reference
- Overview
- Commands
- Overview
- ALTER CONNECTION
- ALTER DATABASE
- ALTER FUNCTION
- ALTER INDEX
- ALTER MATERIALIZED VIEW
- ALTER SCHEMA
- ALTER SECRET
- ALTER SINK
- ALTER SOURCE
- ALTER SUBSCRIPTION
- ALTER SWAP
- ALTER SYSTEM
- ALTER TABLE
- ALTER USER
- ALTER VIEW
- AS CHANGELOG
- BEGIN
- CANCEL JOBS
- COMMENT ON
- COMMIT
- CREATE AGGREGATE
- CREATE CONNECTION
- CREATE DATABASE
- CREATE FUNCTION
- CREATE INDEX
- CREATE MATERIALIZED VIEW
- CREATE SCHEMA
- CREATE SECRET
- CREATE SINK INTO
- CREATE SINK
- CREATE SOURCE
- CREATE TABLE
- CREATE USER
- CREATE VIEW
- DELETE
- DESCRIBE
- DISCARD
- DROP AGGREGATE
- DROP CONNECTION
- DROP DATABASE
- DROP FUNCTION
- DROP INDEX
- DROP MATERIALIZED VIEW
- DROP SCHEMA
- DROP SECRET
- DROP SINK
- DROP SOURCE
- DROP TABLE
- DROP USER
- DROP VIEW
- EXPLAIN
- FLUSH
- GRANT
- INSERT
- RECOVER
- REVOKE
- SELECT
- SET BACKGROUND_DDL
- SET RW_IMPLICIT_FLUSH
- SET TIME ZONE
- SET
- SHOW CLUSTER
- SHOW COLUMNS
- SHOW CONNECTIONS
- SHOW CREATE INDEX
- SHOW CREATE MATERIALIZED VIEW
- SHOW CREATE SINK
- SHOW CREATE SOURCE
- SHOW CREATE TABLE
- SHOW CREATE VIEW
- SHOW CURSORS
- SHOW DATABASES
- SHOW FUNCTIONS
- SHOW INDEXES
- SHOW INTERNAL TABLES
- SHOW JOBS
- SHOW MATERIALIZED VIEWS
- SHOW PARAMETERS
- SHOW PROCESSLIST
- SHOW SCHEMAS
- SHOW SINKS
- SHOW SOURCES
- SHOW SUBSCRIPTION CURSORS
- SHOW TABLES
- SHOW VIEWS
- START TRANSACTION
- UPDATE
- Query syntax
- Data types
- Functions and operators
- Identifiers
- System catalogs
- Psql commands
DESCRIBE
Use the DESCRIBE
command to check the information or execution fragments of a relation (table, source, sink, view, materialized view).
Syntax
Added in v2.4: DESCRIBE FRAGMENTS
.
DESCRIBE relation_name;
DESCRIBE FRAGMENTS relation_name;
Parameter | Description |
---|---|
relation_name | The table, source, sink, view or materialized view whose columns will be listed. |
DESCRIBE
This command shows the columns, primary key, distribution key, indexes, and description (comment) of a specified table, source, sink, view, or materialized view.
DESCRIBE <relation_name>
is similar to SHOW COLUMNS FROM <relation_name>
, but DESCRIBE
also provides information about indexes and table/column comments.
-- Set up a table with columns, primary key, index, and comments
CREATE TABLE customers (
customer_id BIGINT PRIMARY KEY,
name VARCHAR,
email VARCHAR
);
COMMENT ON COLUMN customers.customer_id IS 'Unique identifier for each customer';
COMMENT ON COLUMN customers.name IS 'Name of the customer';
COMMENT ON COLUMN customers.email IS 'Email address of the customer';
COMMENT ON TABLE customers IS 'All customer records';
CREATE INDEX idx_customers_email ON customers(email);
-- Describe the table
DESCRIBE customers;
Output:
| Name | Type | Is Hidden | Description |
| :------------------ | :-------------------------------------------------------------------- | :-------- | :---------------------------------- |
| customer_id | bigint | false | Unique identifier for each customer |
| name | character varying | false | Name of the customer |
| email | character varying | false | Email address of the customer |
| primary key | customer_id | | |
| distribution key | customer_id | | |
| idx_customers_email | index(email ASC, customer_id ASC) include(name) distributed by(email) | | |
| table description | customers | | All customer records |
DESCRIBE FRAGMENTS
This command shows the distributed execution fragments of the job associated with the specified relation (e.g., a materialized view, table, or source). It helps in understanding the job’s physical structure, parallelism, and data flow, which is useful for debugging and optimization.
CREATE TABLE customers (
customer_id BIGINT PRIMARY KEY,
name VARCHAR,
email VARCHAR
);
CREATE TABLE orders (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT,
order_date DATE
);
CREATE MATERIALIZED VIEW mv AS
SELECT name, email, count(*) FROM
orders JOIN customers ON orders.customer_id = customers.customer_id
GROUP BY name, email;
DESCRIBE FRAGMENTS mv;
Sample Output:
Fragment 12 (Actor 50,51,52,53)
StreamMaterialize { columns: [name, email, count], stream_key: [name, email], pk_columns: [name, email], pk_conflict: NoCheck }
├── output: [ customers.name, customers.email, count ]
├── stream key: [ customers.name, customers.email ]
└── StreamHashAgg { group_key: [customers.name, customers.email], aggs: [count] }
├── output: [ customers.name, customers.email, count ]
├── stream key: [ customers.name, customers.email ]
└── MergeExecutor
├── output: [ customers.name, customers.email, orders.order_id, orders.customer_id, customers.customer_id ]
└── stream key: [ orders.order_id, orders.customer_id ]
Fragment 13 (Actor 54,55,56,57)
StreamHashJoin { type: Inner, predicate: orders.customer_id = customers.customer_id }
├── output: [ customers.name, customers.email, orders.order_id, orders.customer_id, customers.customer_id ]
├── stream key: [ orders.order_id, orders.customer_id ]
├── MergeExecutor { output: [ orders.customer_id, orders.order_id ], stream key: [ orders.order_id ] }
└── MergeExecutor { output: [ customers.customer_id, customers.name, customers.email ], stream key: [ customers.customer_id ] }
Fragment 14 (Actor 58,59,60,61)
StreamTableScan { table: orders, columns: [customer_id, order_id] }
├── output: [ orders.customer_id, orders.order_id ]
├── stream key: [ orders.order_id ]
├── Upstream { output: [ customer_id, order_id ], stream key: [] }
└── BatchPlanNode { output: [ customer_id, order_id ], stream key: [] }
Fragment 15 (Actor 62,63,64,65)
StreamTableScan { table: customers, columns: [customer_id, name, email] }
The output has a similar format like EXPLAIN (DISTSQL)
, but DESCRIBE FRAGMENTS
operates on an existing job rather than a new statement being planned.
Was this page helpful?