Rill ingestion and native metrics

Start with the shared setup and dataset. The versioned observations below use the MatrixOne build identified in the overview.

Create the project

Install Rill; the tested version was 0.90.5. Create a project directory containing rill.yaml, connectors/, models/ and metrics/. Set rill.yaml to:

compiler: rillv1

Create connectors/mysql.yaml with the following local-test configuration. Supply actual values privately, and use the appropriate SSL mode/certificates for a remote deployment.

type: connector
driver: mysql
host: MO_HOST
port: 6001
database: bi_tutorial
user: MO_USER
password: REPLACE_WITH_PASSWORD
ssl-mode: DISABLED

Create models/order_metrics.yaml:

type: model
connector: mysql
sql: SELECT * FROM bi_tutorial.order_metrics

Create metrics/order_metrics_metrics.yaml:

type: metrics_view
model: order_metrics
timeseries: ordered_at
dimensions:
  - name: category
    column: category
  - name: region
    column: region
measures:
  - name: paid_orders
    expression: COUNT(*)
  - name: net_amount
    expression: SUM(net_amount)
  - name: buyers
    expression: COUNT(DISTINCT customer_id)
  - name: unit_price
    expression: SUM(gross_amount)/NULLIF(SUM(quantity),0)

Start the project from its parent directory, replacing PROJECT_DIR with its path:

rill start PROJECT_DIR --no-open --port 33004 --port-grpc 49004 --pull-env=false

Wait for model ingestion before querying the metrics view. Restrict access to the local development server and keep connector passwords out of version control.

Query native measures

The local runtime accepts an aggregation request at POST /v1/instances/default/queries/metrics-views/order_metrics_metrics/aggregation with this JSON body:

{
  "dimensions": [{"name": "category"}],
  "measures": [{"name": "net_amount"}, {"name": "buyers"}],
  "sort": [{"name": "category"}],
  "limit": "10000",
  "exact": true
}

For the tutorial dataset, category A must return net amount 130 and buyers 2; category B must return 280 and 2. An aggregation without dimensions must return total buyers 3, not the sum of the category counts. Inspect the metrics view in the installed UI only after ingestion and API result checks succeed; the compatibility run exercised runtime APIs rather than a browser dashboard.

Execution location and precision

This path extracts rows through the native MySQL connector and runs metrics in Rill’s local DuckDB engine. It validates ingestion and the Rill metric definitions; it is not a pushdown test of those aggregations on MatrixOne. Source changes require re-ingestion and any physical tutorial snapshot also requires refresh.

The tested ingestion converted source Decimal values to DOUBLE. Some comparisons differed only by floating-point tails below the declared six-decimal scale, while other large-Decimal comparisons materially lost precision. Check both classes separately; exact: true requests exact aggregation behavior but does not undo ingestion conversion. Use the shared expected results and high-precision transport probe before using this path for financial reconciliation.