@mastra/clickhouse 1.22.1-alpha.0 → 1.22.1

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.
@@ -3,7 +3,7 @@ name: mastra-clickhouse
3
3
  description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/clickhouse"
6
- version: "1.22.1-alpha.0"
6
+ version: "1.22.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.22.1-alpha.0",
2
+ "version": "1.22.1",
3
3
  "package": "@mastra/clickhouse",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -4726,6 +4726,7 @@ function getAggregationSql$2(aggregation, measure = "valueNumber") {
4726
4726
  case "max": return `max(${measure})`;
4727
4727
  case "count": return `toFloat64(count(${measure}))`;
4728
4728
  case "last": return `argMax(${measure}, timestamp)`;
4729
+ case "count_distinct": return `toFloat64(uniq(${measure}))`;
4729
4730
  default: return `sum(${measure})`;
4730
4731
  }
4731
4732
  }
@@ -6179,6 +6180,7 @@ function getAggregationSql(aggregation, measure = "score") {
6179
6180
  case "max": return `max(${measure})`;
6180
6181
  case "count": return `toFloat64(count(${measure}))`;
6181
6182
  case "last": return `argMax(${measure}, timestamp)`;
6183
+ case "count_distinct": return `toFloat64(uniq(${measure}))`;
6182
6184
  default: return `sum(${measure})`;
6183
6185
  }
6184
6186
  }
@@ -6436,7 +6438,7 @@ async function getScoreById(client, scoreId) {
6436
6438
  return rows[0] ? rowToScoreRecord(rows[0]) : null;
6437
6439
  }
6438
6440
  async function getScoreAggregate(client, args) {
6439
- const aggSql = getAggregationSql(args.aggregation);
6441
+ const aggSql = `if(count() = 0, NULL, ${getAggregationSql(args.aggregation)})`;
6440
6442
  const identity = buildScoreIdentityFilter(args);
6441
6443
  const combined = mergeFilters(identity, buildScoresFilterConditions(args.filters));
6442
6444
  const whereClause = toWhereClause(combined);
@@ -8489,11 +8491,11 @@ async function detectDeltaCursorStrategy(client, override, existingStrategy) {
8489
8491
  if (override) return override;
8490
8492
  if (existingStrategy && existingStrategy !== "mixed") return existingStrategy;
8491
8493
  try {
8492
- await client.query({
8494
+ await (await client.query({
8493
8495
  query: `SELECT generateSerialID({counterName:String}) AS cursorId`,
8494
8496
  query_params: { counterName: "mastra_observability_delta_cursor_probe" },
8495
8497
  format: "JSONEachRow"
8496
- });
8498
+ })).json();
8497
8499
  return "serial";
8498
8500
  } catch {
8499
8501
  return "fallback";
@@ -8597,11 +8599,11 @@ var ObservabilityStorageClickhouseVNext = class extends _mastra_core_storage.Obs
8597
8599
  if (this.#deltaCursorStrategy !== null) await reconcileScoreDeltaMv(this.#client, this.#replication, this.#deltaCursorStrategy, this.logger);
8598
8600
  await backfillCurrentScores(this.#client);
8599
8601
  if (this.#retention) await this.applyRetention();
8600
- if (this.#deltaCursorStrategy === "serial") for (const counterName of DELTA_CURSOR_COUNTER_NAMES) await this.#client.query({
8602
+ if (this.#deltaCursorStrategy === "serial") for (const counterName of DELTA_CURSOR_COUNTER_NAMES) await (await this.#client.query({
8601
8603
  query: `SELECT generateSerialID({counterName:String}) AS cursorId`,
8602
8604
  query_params: { counterName },
8603
8605
  format: "JSONEachRow"
8604
- });
8606
+ })).json();
8605
8607
  } catch (error) {
8606
8608
  if (error instanceof _mastra_core_error.MastraError) throw error;
8607
8609
  const causeMessage = error instanceof Error ? error.message : String(error);