com um clique
query
// Compile a semantic query to SQL using airlayer. Use when the user wants to generate SQL from .view.yml schemas, test a query against their semantic layer, or translate dimensions/measures/filters into dialect-specific SQL.
// Compile a semantic query to SQL using airlayer. Use when the user wants to generate SQL from .view.yml schemas, test a query against their semantic layer, or translate dimensions/measures/filters into dialect-specific SQL.
Run a semantic query against the database via airlayer. Use when the user wants to query data through the semantic layer, test view definitions, or debug query results.
Bootstrap a semantic layer from a database. Use when the user wants to create .view.yml files from their warehouse schema, or when starting a new airlayer project from scratch.
Migrate a Cube.js semantic layer to airlayer .view.yml files. Use when the user has existing Cube.js schema files (.js or .yml) they want to convert to airlayer format.
Profile dimensions in the semantic layer to discover data values, ranges, and cardinality. Use when the user wants to understand what data is in a dimension, find valid filter values, or validate view definitions against actual data.
Inspect semantic layer views, dimensions, measures, and entities. Use when the user wants to explore what's available in their .view.yml files or understand the schema structure.
Validate .view.yml semantic layer files using airlayer. Use when the user creates or modifies view files and wants to check for errors.
| name | query |
| description | Compile a semantic query to SQL using airlayer. Use when the user wants to generate SQL from .view.yml schemas, test a query against their semantic layer, or translate dimensions/measures/filters into dialect-specific SQL. |
| allowed-tools | ["Bash","Read","Glob","Grep"] |
| argument-hint | [--dimension view.dim --measure view.measure --filter view.dim:operator:value] |
You are compiling a semantic layer query to SQL using the airlayer CLI.
Ensure airlayer is installed:
which airlayer || cargo install --git https://github.com/oxy-hq/airlayer
.view.yml files in the project. They are typically under a views/ or semantics/views/ directory.views/).find . -name "*.view.yml" -not -path "*/node_modules/*" -not -path "*/cube/*" 2>/dev/null | head -20
Before building a query, inspect what's available:
airlayer inspect```
This lists all views, dimensions, measures, and entities.
## Build and run the query
Use CLI flags (preferred for LLM tool use):
```bash
airlayer query -d <dialect> \
--dimension <view.dimension> \
--measure <view.measure> \
--filter <view.dimension>:<operator>:<value> \
--order <view.member>:desc \
--limit 100
Or JSON input for complex queries:
airlayer query -d <dialect> -q '{
"dimensions": ["view.dimension"],
"measures": ["view.measure"],
"filters": [{"member": "view.dim", "operator": "equals", "values": ["val"]}],
"order": [{"id": "view.measure", "desc": true}],
"limit": 100
}'
$ARGUMENTS
Pick the dialect based on the project's database:
postgres (default), mysql, bigquery, snowflake, duckdb, clickhouse, databricks, redshift, sqlite, domoIf the project has a config.yml with database definitions, use -c config.yml instead of -d.
equals, notEquals, contains, notContains, startsWith, notStartsWith, endsWith, notEndsWith, gt, gte, lt, lte, set, notSet, inDateRange, notInDateRange, beforeDate, beforeOrOnDate, afterDate, afterOrOnDate, onTheDate
--segments view.segment_name (predefined filter conditions)--through entity_name (disambiguate multi-path joins)"time_dimensions": [{"dimension": "view.date_col", "granularity": "month", "date_range": ["2024-01-01", "2024-12-31"]}]"date_range": ["last 7 days"] or ["this month"]"ungrouped": true for raw rows without aggregationairlayer prints the generated SQL to stdout and params to stderr. Show the SQL to the user.