@mastra/clickhouse 1.25.1-alpha.1 → 1.25.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.
package/dist/index.js CHANGED
@@ -8086,7 +8086,13 @@ const COMPARISON_SQL = {
8086
8086
  */
8087
8087
  function compileClickHouseTraceAggregate(plan) {
8088
8088
  const parameters = new ParameterBuilder();
8089
- const ctes = compileClickHouseTraceCandidates(plan, "*", parameters);
8089
+ const ctes = compileClickHouseTraceCandidates(plan, "*", parameters, { oneRootPerTrace: true });
8090
+ ctes.push(`trace_roots AS (
8091
+ SELECT *
8092
+ FROM candidates
8093
+ ORDER BY traceId, dedupeKey
8094
+ LIMIT 1 BY traceId
8095
+ )`);
8090
8096
  const dimensionSql = (field) => {
8091
8097
  if (field.startsWith("metadata.")) return traceMetadataValueSql(parameters.add(field.slice(9), "String"));
8092
8098
  const sql = Object.hasOwn(DIMENSION_SQL, field) ? DIMENSION_SQL[field] : void 0;
@@ -8120,7 +8126,7 @@ function compileClickHouseTraceAggregate(plan) {
8120
8126
  }
8121
8127
  ctes.push(`facts AS (
8122
8128
  SELECT ${factColumns.join(",\n ")}
8123
- FROM candidates r${usageJoin}
8129
+ FROM trace_roots r${usageJoin}
8124
8130
  )`);
8125
8131
  const mixedUnitsSql = "minOrNull(unitMin) != maxOrNull(unitMax)";
8126
8132
  const measureSql = (name) => {