For the complete documentation index, see llms.txt. This page is also available as Markdown.

Scheduler Credit Attribution

Espresso attributes Snowflake credits by preserving routing metadata in query text, reconstructing which original warehouse each query came from, then slicing billed cluster uptime across active and idle intervals.

1. Query comments carry routing context

Every proxied query gets one Espresso Metadata line comment. old_warehouse is the warehouse the user selected; new_warehouse is where Espresso ran it.

// Espresso Metadata: {"query_id": "01b4...", "old_warehouse": "ANALYTICS_WH", "new_warehouse": "_ESPRESSO_POOL_XS_1", "routing_enabled": true}
  • Snowflake stores the comment in QUERY_HISTORY.QUERY_TEXT; attribution parses old_warehouse from it.

  • When query text is censored for export, the metadata comment can still be retained.

2. Cluster uptime is split into query and idle slices

Snowflake bills for warehouse uptime, not just query runtime. For an interval where a cluster is up, Espresso builds boundaries from query starts, query ends, resize/routing state, and metering windows. Each slice is either active, with one or more running queries, or idle. A model allocates shared active slices across the running queries and allocates idle slices using surrounding warehouse activity and routing context.

Overlapping queries on one running cluster with a trailing idle slice
Idle spans are first-class slices; the model attributes them alongside active overlap spans instead of dropping them.

The widths and ratios in the diagrams are illustrative; they show the accounting shape, not a literal allocation for a specific workload.

3. Slices roll up to attributed metering rows

After slicing, Espresso rolls each slice into the original warehouse namespace from the metadata comment and session/routing state. The output is espresso.reporting.warehouse_metering_history, shaped like Snowflake metering history so existing BI queries can read attributed credits.

Uptime slices rolled up into attributed warehouse rows
The model allocates both shared active slices and idle slices into warehouse rows; attributed totals still match the metered total.

Last updated