SHOW COLUMNS IN SEMANTIC VIEW

Lists all queryable columns in a semantic view – dimensions, facts, and metrics – with their data types, expressions, kind, and comments. Private items are excluded from the output.

Syntax

SHOW COLUMNS IN SEMANTIC VIEW <name>

Parameters

<name>

The name of the semantic view. Returns an error if the view does not exist.

Output Columns

Returns one row per queryable column with 8 columns:

Column

Type

Description

database_name

VARCHAR

The DuckDB database containing the semantic view.

schema_name

VARCHAR

The DuckDB schema containing the semantic view.

semantic_view_name

VARCHAR

The semantic view name.

column_name

VARCHAR

The dimension, fact, or metric name.

data_type

VARCHAR

The inferred data type. Empty string if not resolved.

kind

VARCHAR

The column kind: DIMENSION, FACT, METRIC, or DERIVED_METRIC.

expression

VARCHAR

The SQL expression defining the column.

comment

VARCHAR

The comment text. Empty string if no comment is set.

Kind Values

Kind

Description

DIMENSION

A grouping expression from the DIMENSIONS clause.

FACT

A row-level expression from the FACTS clause.

METRIC

A base metric (scoped to a table) from the METRICS clause.

DERIVED_METRIC

A derived metric (no table alias, references other metrics) from the METRICS clause.

PRIVATE Exclusion

Metrics and facts marked PRIVATE are excluded from the output. Only PUBLIC items (the default) appear. This matches the behavior of wildcard expansion in semantic_view() queries.

Sort Order

Rows are sorted by kind (alphabetically: DERIVED_METRIC, DIMENSION, FACT, METRIC) and then by column_name within each kind.

Examples

CREATE SEMANTIC VIEW shop AS
TABLES (o AS orders PRIMARY KEY (id))
FACTS (o.raw_amount AS o.quantity * o.price COMMENT = 'Line total')
DIMENSIONS (o.region AS o.region)
METRICS (
    o.revenue AS SUM(o.quantity * o.price),
    avg_order AS revenue / COUNT(*)
);

SHOW COLUMNS IN SEMANTIC VIEW shop;
┌───────────────┬─────────────┬────────────────────┬─────────────┬───────────┬────────────────┬───────────────────────────┬────────────┐
│ database_name │ schema_name │ semantic_view_name │ column_name │ data_type │ kind           │ expression                │ comment    │
├───────────────┼─────────────┼────────────────────┼─────────────┼───────────┼────────────────┼───────────────────────────┼────────────┤
│ memory        │ main        │ shop               │ avg_order   │ DOUBLE    │ DERIVED_METRIC │ revenue / COUNT(*)        │            │
│ memory        │ main        │ shop               │ region      │ VARCHAR   │ DIMENSION      │ o.region                  │            │
│ memory        │ main        │ shop               │ raw_amount  │ DOUBLE    │ FACT           │ o.quantity * o.price      │ Line total │
│ memory        │ main        │ shop               │ revenue     │ BIGINT    │ METRIC         │ SUM(o.quantity * o.price) │            │
└───────────────┴─────────────┴────────────────────┴─────────────┴───────────┴────────────────┴───────────────────────────┴────────────┘

Error: view does not exist:

SHOW COLUMNS IN SEMANTIC VIEW nonexistent;
Error: Semantic view 'nonexistent' not found