omx sql
Convert raw SQL queries into semantic layer metric definitions.
Commands
omx sql convert
Convert a SQL query or .sql file into a metric definition.
bash
omx sql convert "SELECT SUM(amount) FROM orders WHERE status = 'paid'"
omx sql convert queries/revenue.sql --format yaml
omx sql convert "SELECT ..." --import # convert + push to serveromx sql convert-batch
Convert all .sql files in a directory.
bash
omx sql convert-batch ./queries/ --format yaml --output metrics.yaml
omx sql convert-batch ./queries/ --import # convert + push to serveromx sql inspect
Inspect what would be extracted from a SQL query without converting.
bash
omx sql inspect "SELECT country, SUM(amount) FROM orders GROUP BY country"Output:
Name: sum_amount
Tables: orders
Aggregations: 1
- SUM(amount) AS amount
Dimensions: country
Time column: (not detected)
Tags: aggregate, financeRequires pip install onlymetrix[sql] for the sqlglot dependency.