Explore
Explore
The explore command parses a file and lists the concepts, datasources, and imports in its environment. It answers "what can I query from this file?" without making you read the raw source.
This matters most on fact models, which import a handful of dimensions and can easily expose several hundred concepts. The default view collapses concepts by namespace, so a 378-concept import becomes roughly 25 group lines.
Usage
trilogy explore <path> [options]
Arguments
| Argument | Description |
|---|---|
path | Path to a Trilogy file to parse. |
Options
| Option | Description |
|---|---|
--show [all|concepts|datasources|imports|groups] | Which section to print. Default groups. |
--purpose TEXT | Filter concepts by purpose: key, property, metric, constant, rowset. Repeatable. |
--regex TEXT | Case-insensitive regex filter over concept addresses. Repeatable, OR semantics. |
--include-hidden | Include concepts normally hidden from public view. |
--include-builtins | Include internal/builtin concepts. |
--expand-imports | Render imported concepts in full instead of collapsing to a name-only listing. |
--expand-roles | Render every role-played conformed dimension in full. |
Full Examples
# What does this model expose?
trilogy explore raw/orders.preql
# The full flat concept table
trilogy explore raw/orders.preql --show concepts
# Everything, including datasources and imports
trilogy explore raw/orders.preql --show all
# Just the metrics
trilogy explore models/sales.preql --purpose metric
# Anything date-related
trilogy explore models/sales.preql --regex 'date\.(year|week_seq)'
# A bare word matches as a substring
trilogy explore models/sales.preql --regex customer
Sample output:
Available Concepts (1 namespaces, 4 concepts)
# (root)
order_id : enum<1, 2, 3>
KEY
amount : float
PROP @order_id
customer_id : enum<10, 11>
PROP @order_id
order_date : date
PROP @order_id
Collapsing Rules
Two defaults keep the output small, and both can be turned off:
Imports collapse. A fact file typically pulls in five to ten dimensions, each contributing dozens of concepts. Imported concepts are listed by name only so local declarations stay readable. --expand-imports renders them in full. Passing --regex also bypasses the collapse - when you are filtering, you want matching imports in full.
Role-played dimensions collapse. Namespaces parsed from the same source file with an identical shape - the eight date roles a fact plays, say - collapse to one canonical schema plus same_as references and a conformed map. This is most of the token savings on fact files. --expand-roles gives the literal per-role dump.
Notes
--regexuses Pythonre.search, so full Python regex syntax works- A malformed pattern exits non-zero with the underlying
re.errormessage - Pairs well with
trilogy ingest: ingest a table, then explore it