Serve Data via OData
On this page
Add @expose to any model. Run ondatrasql odata <port>. BI tools connect directly.
1. Mark Models for Serving
Add @expose to any materialized SQL model:
-- models/mart/revenue.sql
-- @kind: table
-- @expose order_id
SELECT
order_id,
customer,
amount,
order_date
FROM staging.orders
The column after @expose is the OData primary key.
2. Run the Pipeline
ondatrasql run
3. Start the Server
ondatrasql odata 8090
OData server starting...
Endpoint: http://127.0.0.1:8090/odata
mart_revenue (4 columns)
4. Connect a Tool
Power BI
- Get Data → OData Feed
- Enter:
http://your-server:8090/odata - Select tables → Load
Excel
- Data → Get Data → From Other Sources → From OData Feed
- Enter:
http://your-server:8090/odata - Select tables → Load
Tableau
- Connect → OData
- Enter:
http://your-server:8090/odata
Grafana
- Install the Infinity datasource plugin
- Connections → Data Sources → Add data source → Infinity
- URL:
http://your-server:8090/odata/mart_revenue - Set Rows/Root to
value
Spotfire
- Data → Add Data Connection → OData
- Enter:
http://your-server:8090/odata
Salesforce
- Setup → External Data Sources → New
- Type: OData 4.0
- URL:
http://your-server:8090/odata
curl / Python
curl "http://localhost:8090/odata/mart_revenue?\$top=5" | jq .
import pandas as pd, requests
df = pd.json_normalize(requests.get("http://localhost:8090/odata/mart_revenue").json()["value"])
For the full query reference, see OData API Reference.
OndatraSQL