How to Use Wildcard Selection¶
This guide shows how to use the alias.* wildcard pattern to select all dimensions, metrics, or facts belonging to a specific table alias in a single expression, instead of listing each name individually.
Prerequisites:
A working semantic view with multiple dimensions and/or metrics (see Multi-Table Semantic Views)
Familiarity with semantic_view() queries
Wildcard Syntax¶
Use table_alias.* in any of the three list parameters (dimensions, metrics, facts) to expand to all items scoped to that table alias:
SELECT * FROM semantic_view('analytics',
dimensions := ['o.*'],
metrics := ['o.*']
);
This expands o.* to all dimensions scoped to table alias o and all metrics scoped to o.
PRIVATE Item Exclusion¶
Wildcard expansion excludes PRIVATE metrics and facts. Only PUBLIC items (the default) are included in the expanded list.
Given a view with both public and private metrics:
CREATE SEMANTIC VIEW sales AS
TABLES (o AS orders PRIMARY KEY (id))
DIMENSIONS (o.region AS o.region)
METRICS (
o.revenue AS SUM(o.amount),
PRIVATE o.internal_cost AS SUM(o.cost),
profit AS revenue - internal_cost
);
-- o.* expands to ['revenue'] only -- internal_cost is PRIVATE
SELECT * FROM semantic_view('sales',
dimensions := ['region'],
metrics := ['o.*']
);
Deduplication¶
When an item appears both explicitly and via a wildcard, it appears only once in the expanded list:
-- 'region' is listed explicitly AND is part of o.*
-- Result: ['region', 'status'] (region appears once)
SELECT * FROM semantic_view('sales',
dimensions := ['region', 'o.*']
);
Bare Wildcard Rejection¶
Warning
Unqualified * (bare wildcard) is not supported. All wildcards must be qualified with a table alias.
-- This fails:
SELECT * FROM semantic_view('sales',
dimensions := ['*']
);
unqualified wildcard '*' is not supported. Use table_alias.* to select all items
for a specific table.
Wildcards for Facts¶
The facts parameter also supports wildcard expansion:
SELECT * FROM semantic_view('analytics',
facts := ['li.*']
);
This expands to all public facts scoped to table alias li.
Troubleshooting¶
- Unknown table alias in wildcard
The table alias must match an alias declared in the
TABLESclause. The error lists available aliases:unknown table alias 'x' in wildcard 'x.*'. Available aliases: [o, c, li].- Empty expansion
If the wildcard expands to an empty list (no items scoped to that alias, or all are private), the query may fail with an empty request error. Verify that the alias has public items defined.