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

  1. Get DataOData Feed
  2. Enter: http://your-server:8090/odata
  3. Select tables → Load

Excel

  1. DataGet DataFrom Other SourcesFrom OData Feed
  2. Enter: http://your-server:8090/odata
  3. Select tables → Load

Tableau

  1. ConnectOData
  2. Enter: http://your-server:8090/odata

Grafana

  1. Install the Infinity datasource plugin
  2. ConnectionsData SourcesAdd data sourceInfinity
  3. URL: http://your-server:8090/odata/mart_revenue
  4. Set Rows/Root to value

Spotfire

  1. DataAdd Data ConnectionOData
  2. Enter: http://your-server:8090/odata

Salesforce

  1. SetupExternal Data SourcesNew
  2. Type: OData 4.0
  3. 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.