@mastra/duckdb 1.17.0 → 1.18.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const require_features = require("./features-CBdrOdEO.cjs");
1
+ const require_features = require("./features-hDeKZlYS.cjs");
2
2
  let _mastra_core_error = require("@mastra/core/error");
3
3
  let _mastra_core_storage = require("@mastra/core/storage");
4
4
  _mastra_core_storage = require_features.__toESM(_mastra_core_storage, 1);
@@ -4508,6 +4508,13 @@ const SPAN_DIMENSION_SQL = Object.fromEntries([
4508
4508
  "model",
4509
4509
  "provider"
4510
4510
  ].map((field) => [field, `r.${field}`]));
4511
+ /** Quantile for each percentile statistic of a time-to-first measure. */
4512
+ const STATISTIC_PERCENTILES = {
4513
+ p50: .5,
4514
+ p90: .9,
4515
+ p95: .95,
4516
+ p99: .99
4517
+ };
4511
4518
  const PERCENTILES = {
4512
4519
  "duration.p50": .5,
4513
4520
  "duration.p90": .9,
@@ -4586,6 +4593,8 @@ function compileDuckDBAggregate(plan, options, source) {
4586
4593
  values.push(...compiled.values);
4587
4594
  }
4588
4595
  factColumns.push(`CAST(${durationMsSql("r.startedAt", "r.endedAt")} AS DOUBLE) AS durationMs`, `r.error IS NOT NULL AS isError`);
4596
+ const timeToFirstFields = new Set(plan.measures.map((measure) => measureRule(measure.name)?.field));
4597
+ for (const field of timeToFirstFields) if (field) factColumns.push(`CAST(r.${field} AS DOUBLE) AS ${field}`);
4589
4598
  if (plan.interval !== void 0) {
4590
4599
  const intervalMs = _mastra_core_storage.TRACE_AGGREGATE_INTERVAL_MS[plan.interval];
4591
4600
  if (intervalMs === void 0) throw new Error(`Unsupported trusted trace-aggregate interval: ${plan.interval}`);
@@ -4621,6 +4630,16 @@ function compileDuckDBAggregate(plan, options, source) {
4621
4630
  const measureSql = (name, alias = "") => {
4622
4631
  const column = (name) => `${alias}${name}`;
4623
4632
  if (name === "count") return "CAST(count(*) AS DOUBLE)";
4633
+ const timeToFirst = measureRule(name);
4634
+ if (timeToFirst?.field) {
4635
+ const value = column(timeToFirst.field);
4636
+ if (timeToFirst.statistic === "count") return `CAST(count(${value}) AS DOUBLE)`;
4637
+ if (timeToFirst.statistic === "avg") return `avg(${value})`;
4638
+ if (timeToFirst.statistic === "min") return `min(${value})`;
4639
+ if (timeToFirst.statistic === "max") return `max(${value})`;
4640
+ const quantile = timeToFirst.statistic && STATISTIC_PERCENTILES[timeToFirst.statistic];
4641
+ if (quantile !== void 0) return `quantile_cont(${value}, ${quantile})`;
4642
+ }
4624
4643
  if (name === "errorCount") return `CAST(count_if(${column("isError")}) AS DOUBLE)`;
4625
4644
  if (name === "errorRate") return `CAST(count_if(${column("isError")}) AS DOUBLE) / count(*)`;
4626
4645
  if (name === "duration.avg") return `avg(${column("durationMs")})`;
@@ -6390,6 +6409,7 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends _mastr
6390
6409
  "metric-discovery",
6391
6410
  "trace-query",
6392
6411
  "trace-aggregate",
6412
+ ...require_features.aggregateTimeToFirstFeatures,
6393
6413
  ...require_features.spanQueryFeatures,
6394
6414
  ...require_features.spanAggregateFeatures,
6395
6415
  ...typeof _mastra_core_storage.planThreadRowsQuery === "function" ? ["thread-query-rows"] : [],
@@ -6416,6 +6436,7 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends _mastr
6416
6436
  "delta-polling",
6417
6437
  "trace-query",
6418
6438
  "trace-aggregate",
6439
+ ...require_features.aggregateTimeToFirstFeatures,
6419
6440
  ...require_features.spanQueryFeatures,
6420
6441
  ...require_features.spanAggregateFeatures,
6421
6442
  ...typeof _mastra_core_storage.planThreadRowsQuery === "function" ? ["thread-query-rows"] : [],
@@ -6592,4 +6613,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends _mastr
6592
6613
  };
6593
6614
  exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
6594
6615
 
6595
- //# sourceMappingURL=observability-B_ARB4Uv.cjs.map
6616
+ //# sourceMappingURL=observability-DFLDzgiC.cjs.map