Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),

### Added

- **Semantic metrics** — a workspace-level `semantic.metrics:` block composing measures into named, governed business numbers, queryable by their dot-free name through the existing `semantic query` surface (CLI, MCP, gRPC — no wire change): `pawrly semantic query aov --by orders.status`.
- `ratio` (numerator/denominator with `NULLIF` guard and `DOUBLE` cast) and `derived` (arithmetic over `{member}` references) kinds, including cross-model ratios via the aggregate-locality compiler.
- `cumulative` (running total / grain-to-date / trailing window), `offset` (period-over-period value/delta/growth), and `share` (percent-of-partition) kinds. Window metrics join onto a dense time axis — generated automatically or pinned to a declared `semantic.time_spine:` table — so running totals and period-over-period stay calendar-correct across gaps in the data.
- Governed filters at three levels — metric-level, per-ratio-operand, and per-derived-token — all pushed down to leaf `FILTER (WHERE …)` clauses; metrics may reference other metrics.
- Config validation: reference resolution, cycle detection, name collisions, window-metric time-dimension and period checks.

- **Custom materialize namespaces** — pass a namespace when creating a materialized table to target an isolated store (own storage subdir, manifest, and SQL address), so the same name never collides across callers: `pawrly materialize <name> "<sql>" --namespace <ns>`, queryable as `<ns>.materialized.<name>`.
- Threaded through every surface: a `namespace` field on the `Materialize` / `DropMaterialized` / `ListEntries` RPCs, `?namespace=` on the REST endpoints, `--namespace` on `pawrly materialize` and `pawrly cache list`, a `namespace` argument on the MCP tools, and optional parameters in the TypeScript / Python SDKs. Empty or omitted = the default workspace namespace (fully backward compatible).
- Namespaces are created on first write and resolve in SQL on demand — including after a daemon restart and when written by another process sharing the storage root. Reserved names (`pawrly`, `materialized`, `system`, `information_schema`) and unsafe segments are rejected.
Expand Down
16 changes: 3 additions & 13 deletions crates/pawrly-client/src/rest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,11 @@ impl RestEngineClient {
}
}

/// Turn a `{ "error": { code, message } }` envelope into an `EngineError`,
/// preserving the code where a matching variant exists.
/// Turn a `{ "error": { code, message } }` envelope into an `EngineError`.
fn rest_error(body: &Value) -> EngineError {
let code = body["error"]["code"].as_str().unwrap_or("PAWRLY_INTERNAL");
let msg = body["error"]["message"].as_str().unwrap_or("").to_string();
match code {
"PAWRLY_UNKNOWN_TABLE" => EngineError::UnknownTable(msg),
"PAWRLY_UNKNOWN_FUNCTION" => EngineError::UnknownFunction(msg),
"PAWRLY_INVALID_SQL" => EngineError::InvalidSql(msg),
"PAWRLY_SEMANTIC_PLAN" => EngineError::SemanticPlan(msg),
"PAWRLY_TIMEOUT" => EngineError::Timeout(Duration::ZERO),
"PAWRLY_CANCELLED" => EngineError::Cancelled,
"PAWRLY_UNSUPPORTED" => EngineError::Unsupported(msg),
_ => EngineError::Internal(format!("{code}: {msg}")),
}
let msg = body["error"]["message"].as_str().unwrap_or("");
EngineError::from_wire(code, msg)
}

fn require_namespace_echo(requested: Option<&str>, resp: &Value) -> Result<(), EngineError> {
Expand Down
9 changes: 9 additions & 0 deletions crates/pawrly-config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ pub struct SemanticConfig {

#[serde(default)]
pub models: Vec<SemanticModel>,

/// Workspace-level metrics composed over model measures
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub metrics: Vec<pawrly_core::semantic::Metric>,

/// Optional calendar table pinning the dense date axis window metrics run
/// over.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub time_spine: Option<pawrly_core::semantic::TimeSpine>,
}

/// One secret backend in the resolution chain.
Expand Down
Loading
Loading