Skip to main content

Part 4: Your First Query

For Everyone 10 min read
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:

# 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)

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

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
}'

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"
}'
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

CubeDescriptionMeasuresDimensions
sales_ordersSales order analytics159
billingInvoice/credit memo analytics1510
deliveriesShipping/logistics analytics1612

Key Measures

Sales Orders:

  • net_revenue, gross_revenue, cost_value
  • gross_profit, gross_margin_pct
  • order_count, avg_order_value
  • fulfillment_rate, delivered_orders

Billing:

  • invoice_count, credit_memo_count
  • net_revenue, gross_profit
  • avg_invoice_value

Deliveries:

  • delivery_count, on_time_deliveries
  • on_time_rate, avg_days_late
  • total_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

Next Steps