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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"record": {
"state_database": null,
"state_schema": "main",
"observation_id": "cost-000",
"run_id": "build-1",
"orchestration_run_id": null,
"attempt": 1,
"resource_type": "model",
"resource_name": "orders",
"warehouse_name": "TRANSFORM_WH",
"warehouse_size": "Small",
"warehouse_type": "STANDARD",
"cluster_number": 1,
"query_count": 2,
"attributed_seconds": "120.000",
"bytes_scanned": 1048576,
"estimated_credits": "0.0667",
"estimated_usd": "0.2000",
"status": "complete",
"statements_expected": 4,
"statements_observed": 4,
"limitations": "[]",
"target_name": "development",
"run_started_at": "2026-01-01T00:00:00Z",
"run_completed_at": "2026-01-01T00:10:00Z",
"observed_at": "2026-01-01T00:15:00Z"
},
"observations": [
{"observation_id": "build-1-run-1", "hours_ago": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_type": "_total", "resource_name": "build-1", "warehouse_name": "", "warehouse_size": "", "warehouse_type": null, "cluster_number": null, "status": "partial", "estimated_credits": "0.15", "estimated_usd": "0.45", "statements_observed": 2},
{"observation_id": "build-1-orders-1", "hours_ago": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "status": "partial", "estimated_credits": "0.10", "estimated_usd": "0.30", "statements_observed": 2},
{"observation_id": "build-1-payments-1", "hours_ago": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_name": "payments", "status": "partial", "estimated_credits": "0.03", "estimated_usd": "0.09", "statements_observed": 2},
{"observation_id": "build-1-customers-1", "hours_ago": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_name": "customers", "status": "partial", "estimated_credits": "0.05", "estimated_usd": "0.15", "statements_observed": 2},
{"observation_id": "build-1-run-2", "hours_ago": 2, "attempt": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_type": "_total", "resource_name": "build-1", "warehouse_name": "", "warehouse_size": "", "warehouse_type": null, "cluster_number": null, "estimated_credits": "0.40", "estimated_usd": "1.20"},
{"observation_id": "build-1-orders-2", "hours_ago": 2, "attempt": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "estimated_credits": "0.25", "estimated_usd": "0.75"},
{"observation_id": "build-1-setup-2", "hours_ago": 2, "attempt": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_type": "run", "resource_name": "development", "estimated_credits": "0.05", "estimated_usd": "0.15"},
{"observation_id": "build-1-customers-2", "hours_ago": 2, "attempt": 2, "orchestration_run_id": "00000000-0000-0000-0000-000000001302", "resource_name": "customers", "estimated_credits": "0.10", "estimated_usd": "0.30"},
{"observation_id": "build-2-run-1", "hours_ago": 5, "run_id": "build-2", "resource_type": "_total", "resource_name": "build-2", "warehouse_name": "", "warehouse_size": "", "warehouse_type": null, "cluster_number": null, "estimated_credits": "0.20", "estimated_usd": null},
{"observation_id": "build-2-orders-1", "hours_ago": 5, "run_id": "build-2", "warehouse_name": "LOAD_WH", "warehouse_size": "X-Small", "estimated_credits": "0.20", "estimated_usd": null},
{"observation_id": "build-3-run-1", "hours_ago": 240, "run_id": "build-3", "resource_type": "_total", "resource_name": "build-3", "warehouse_name": "", "warehouse_size": "", "warehouse_type": null, "cluster_number": null, "estimated_credits": "5.00", "estimated_usd": "15.00"},
{"observation_id": "build-3-orders-1", "hours_ago": 240, "run_id": "build-3", "estimated_credits": "5.00", "estimated_usd": "15.00"}
]
}
274 changes: 273 additions & 1 deletion clients/typescript/src/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,22 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/cost": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["readPersonCostSummary"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/fingerprint": {
parameters: {
query?: never;
Expand Down Expand Up @@ -546,6 +562,22 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/nodes/{node_key}/cost": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["listPersonNodeCosts"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/nodes/{node_key}/runs": {
parameters: {
query?: never;
Expand Down Expand Up @@ -642,6 +674,22 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/runs/{run_id}/cost": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get: operations["readPersonRunCost"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/control/locations/{location_id}/targets/{target}/runs/{run_id}/events": {
parameters: {
query?: never;
Expand Down Expand Up @@ -1614,6 +1662,45 @@ export interface components {
access: components["schemas"]["PersonAccess"];
login_mode: components["schemas"]["LoginMode"];
};
/** @description Estimated query cost of one group, such as a job, a warehouse size or a node. */
CostGroup: {
/** Format: double */
credits: number;
/** @description The group's name; None for builds no server run started, or a resource without a warehouse. */
key?: string | null;
/**
* Format: int64
* @description Builds that contributed, counted once each.
*/
runs: number;
/** Format: double */
seconds: number;
/**
* Format: double
* @description None when any of the group's observations had no configured credit price.
*/
usd?: number | null;
};
/** @description A target's estimated query cost over a window, from the latest observation of each run. */
CostSummaryRecord: {
by_job: components["schemas"]["CostGroup"][];
/** @description Every node that ran, keyed `<resource_type>:<resource_name>` like catalog node keys. */
by_node: components["schemas"]["CostGroup"][];
by_warehouse_size: components["schemas"]["CostGroup"][];
/** Format: double */
credits: number;
/**
* Format: int64
* @description Runs whose cost is still pending or partial, which a later build re-reads.
*/
incomplete_runs: number;
/** Format: int64 */
runs: number;
/** Format: date-time */
since: string;
/** Format: double */
usd?: number | null;
};
/** @description One stretch of the cursor, as raw bound texts. */
CoverageBatch: {
end: string;
Expand Down Expand Up @@ -2044,6 +2131,23 @@ export interface components {
MutationResponse: {
applied: boolean;
};
/** @description One build's estimated query cost of one node, across every warehouse it used. */
NodeCostRecord: {
/** Format: double */
credits: number;
orchestration_run_id?: string | null;
/** Format: int64 */
query_count: number;
run_id: string;
/** Format: date-time */
run_started_at: string;
/** Format: double */
seconds: number;
/** @description The collection status of the whole build. */
status: string;
/** Format: double */
usd?: number | null;
};
/** @enum {string} */
NodeEventKind: "success" | "failed" | "recovered";
/** @enum {string} */
Expand Down Expand Up @@ -3281,7 +3385,7 @@ export interface components {
* @description Catalog observations require full scans; only immutable history supports a watermark.
* @enum {string}
*/
WarehouseHistoryKind: "fingerprints" | "source_freshness" | "audit_results" | "janitor_events" | "migrations" | "old_name_views" | "microbatches" | "column_migrations" | "node_results" | "consumption" | "observations" | "catalog" | "statistics";
WarehouseHistoryKind: "fingerprints" | "source_freshness" | "audit_results" | "janitor_events" | "migrations" | "old_name_views" | "microbatches" | "column_migrations" | "node_results" | "consumption" | "observations" | "resource_costs" | "catalog" | "statistics";
/** @description Warehouse cleanup facts do not authorize control-plane deletion or worker recovery. */
WarehouseJanitorRecord: {
archive_name: string;
Expand Down Expand Up @@ -3343,6 +3447,43 @@ export interface components {
state_schema: string;
value: string;
};
/** @description One estimated query cost observation of a run, resource and warehouse; refreshes append. */
WarehouseResourceCostRecord: {
/** Format: int64 */
attempt: number;
attributed_seconds: string;
/** Format: int64 */
bytes_scanned: number;
/** Format: int64 */
cluster_number?: number | null;
estimated_credits: string;
estimated_usd?: string | null;
limitations: string;
observation_id: string;
/** Format: date-time */
observed_at: string;
orchestration_run_id?: string | null;
/** Format: int64 */
query_count: number;
resource_name: string;
resource_type: string;
/** Format: date-time */
run_completed_at: string;
run_id: string;
/** Format: date-time */
run_started_at: string;
state_database?: string | null;
state_schema: string;
/** Format: int64 */
statements_expected: number;
/** Format: int64 */
statements_observed: number;
status: string;
target_name?: string | null;
warehouse_name: string;
warehouse_size: string;
warehouse_type?: string | null;
};
/** @description Physical namespace of SQLBuild's source-freshness state table, never a source query. */
WarehouseStateLocation: {
database?: string | null;
Expand Down Expand Up @@ -4448,6 +4589,47 @@ export interface operations {
};
};
};
readPersonCostSummary: {
parameters: {
query?: {
/** @description Runs that started in the last this many days; defaults to 7, capped at 90 */
days?: number;
};
header?: never;
path: {
location_id: string;
target: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Estimated query cost by job, warehouse size and node, most expensive first */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["CostSummaryRecord"];
};
};
/** @description Session rejected */
401: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorBody"];
};
};
};
};
readPersonFingerprint: {
parameters: {
query: {
Expand Down Expand Up @@ -4791,6 +4973,50 @@ export interface operations {
};
};
};
listPersonNodeCosts: {
parameters: {
query?: {
/** @description Builds that started in the last this many days; defaults to 7, capped at 90 */
days?: number;
/** @description Maximum builds; defaults to 100, capped at 1000 */
limit?: number;
};
header?: never;
path: {
location_id: string;
target: string;
node_key: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description The node's estimated query cost in each build, newest first */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["NodeCostRecord"][];
};
};
/** @description Session rejected */
401: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorBody"];
};
};
};
};
listPersonNodeRuns: {
parameters: {
query?: {
Expand Down Expand Up @@ -5051,6 +5277,52 @@ export interface operations {
};
};
};
readPersonRunCost: {
parameters: {
query?: never;
header?: never;
path: {
location_id: string;
target: string;
run_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description The latest estimated query cost observation of the run and of each resource and warehouse it used; empty when none was synced */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["WarehouseResourceCostRecord"][];
};
};
/** @description Session rejected */
401: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ApiErrorBody"];
};
};
/** @description Run not found for a person who may view the whole target */
404: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
listPersonRunEvents: {
parameters: {
query?: {
Expand Down
2 changes: 1 addition & 1 deletion crates/sqlbuild-analysis/src/janitor_planning/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use sqlbuild_core::constants::STATE_TABLE_NAMES;

/// SQLBuild state tables the janitor never acts on.
pub const BUILT_IN_EXCLUDE_PATTERNS: [&str; 11] = STATE_TABLE_NAMES;
pub const BUILT_IN_EXCLUDE_PATTERNS: [&str; 12] = STATE_TABLE_NAMES;
/// Prefix of every strict janitor archive name.
pub const ARCHIVE_NAME_PREFIX: &str = "_SQB_ARCHIVE__";
/// Separator between archive name segments.
Expand Down
Loading
Loading