Part 4: Your First Query
What you'll learn
- Load and compile the tutorial project
- Execute semantic queries via CLI and API
- Explore column-level lineage
- Use AI-powered features (optional)
Step 1: Load the Tutorial Project
The tutorial/ directory contains a SAP Sales Analytics project. Let's compile it:
- Using CLI
- Using API
# Compile the project
olytix-core compile --project ./tutorial
# List available cubes
olytix-core list cubes --project ./tutorial
Expected output:
Compiling project: ./tutorial
✓ Sources loaded: 1
✓ Models compiled: 3
✓ Cubes compiled: 8
✓ Metrics compiled: 17
Available cubes:
- sales_orders (15 measures, 9 dimensions)
- billing (15 measures, 10 dimensions)
- deliveries (16 measures, 12 dimensions)
- date (0 measures, 19 dimensions)
- customer (0 measures, 17 dimensions)
- material (0 measures, 17 dimensions)
- sales_org (0 measures, 13 dimensions)
- order_type (0 measures, 7 dimensions)
# Load project via API
curl -X POST http://localhost:8000/api/v1/unified/load \
-H "Content-Type: application/json" \
-d '{"project_path": "./tutorial"}'
# Compile project
curl -X POST http://localhost:8000/api/v1/unified/compile \
-H "Content-Type: application/json" \
-d '{"project_path": "./tutorial", "full": true}'
Step 2: Explore the Project
View Dependency Graph
See how all artifacts connect:
olytix-core graph --project ./tutorial
Generate a visual diagram:
olytix-core graph --project ./tutorial --format mermaid
Describe a Cube
Get detailed information about a specific cube:
olytix-core describe cube.sales_orders --project ./tutorial
Output includes:
- All measures with their types and SQL expressions
- All dimensions with their types
- Joins to other cubes
- Pre-aggregation definitions
Step 3: Run Semantic Queries
Query via CLI
# Revenue by country (top 10)
olytix-core query \
--cube sales_orders \
--measures net_revenue,order_count \
--dimensions customer.country_name \
--order "net_revenue:desc" \
--limit 10 \
--project ./tutorial
Query via API
- Revenue by Country
- Monthly Trend
- Fulfillment Rate
curl -X POST http://localhost:8000/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"cube": "sales_orders",
"measures": ["net_revenue", "order_count"],
"dimensions": ["customer.country_name"],
"order": [{"field": "net_revenue", "direction": "desc"}],
"limit": 10
}'
curl -X POST http://localhost:8000/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"cube": "sales_orders",
"measures": ["net_revenue", "gross_margin_pct"],
"dimensions": ["date.year", "date.month_name"],
"order": [{"field": "date.year", "direction": "asc"}]
}'
curl -X POST http://localhost:8000/api/v1/query \
-H "Content-Type: application/json" \
-d '{
"cube": "sales_orders",
"measures": ["order_count", "delivered_orders", "fulfillment_rate"],
"dimensions": ["customer.region_name"]
}'
Sample Response:
{
"data": [
{
"customer.country_name": "United States",
"net_revenue": 15432567.89,
"order_count": 12543
},
{
"customer.country_name": "Germany",
"net_revenue": 8765432.10,
"order_count": 7821
}
],
"meta": {
"cube": "sales_orders",
"total_rows": 10,
"query_time_ms": 234
}
}
Step 4: Explore Lineage
One of Olytix Core's most powerful features is column-level lineage tracking.
Trace a Measure's Lineage
# See where net_revenue comes from
olytix-core lineage trace "sales_orders.net_revenue" --project ./tutorial
Output:
Lineage for: sales_orders.net_revenue
Source → Transformation → Measure
═══════════════════════════════════════════════════════════════
source.gold.fact_sales_order_items.net_value
↓ [DIRECT]
cube.sales_orders.measure.net_revenue (SUM)
Upstream Dependencies
What feeds into a measure:
olytix-core lineage upstream "sales_orders.gross_profit" --project ./tutorial
Downstream Impact
What's affected if a source column changes:
olytix-core lineage downstream "source.gold.fact_sales_order_items.net_value" --project ./tutorial
Via API
# Get full lineage graph
curl http://localhost:8000/api/v1/lineage/graph
# Get upstream lineage for a measure
curl http://localhost:8000/api/v1/lineage/measure/sales_orders/net_revenue
# Impact analysis
curl -X POST http://localhost:8000/api/v1/lineage/impact \
-H "Content-Type: application/json" \
-d '{"column_id": "source.gold.fact_sales_order_items.column.net_value"}'
Step 5: AI-Powered Features (Optional)
If you installed AI features and have an API key configured:
Natural Language Queries
curl -X POST http://localhost:8000/api/v1/search/nl-query \
-H "Content-Type: application/json" \
-d '{
"query": "Show me total revenue by customer country for the top 10 customers"
}'
Semantic Search
curl -X POST http://localhost:8000/api/v1/search \
-H "Content-Type: application/json" \
-d '{
"query": "revenue metrics",
"types": ["measure"],
"limit": 5
}'
Autocomplete
curl -X POST http://localhost:8000/api/v1/search/autocomplete \
-H "Content-Type: application/json" \
-d '{
"query": "rev",
"context": {"cube_name": "sales_orders"}
}'
Available Cubes Reference
Fact Cubes
| Cube | Description | Measures | Dimensions |
|---|---|---|---|
sales_orders | Sales order analytics | 15 | 9 |
billing | Invoice/credit memo analytics | 15 | 10 |
deliveries | Shipping/logistics analytics | 16 | 12 |
Key Measures
Sales Orders:
net_revenue,gross_revenue,cost_valuegross_profit,gross_margin_pctorder_count,avg_order_valuefulfillment_rate,delivered_orders
Billing:
invoice_count,credit_memo_countnet_revenue,gross_profitavg_invoice_value
Deliveries:
delivery_count,on_time_deliverieson_time_rate,avg_days_latetotal_weight,total_volume
Congratulations!
You've completed the Olytix Core quick start tutorial! You now know how to:
- Install and configure Olytix Core
- Connect to your data warehouse
- Run semantic queries via CLI and API
- Explore column-level lineage