@mastra/clickhouse 1.15.1 → 1.15.2-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.
- package/CHANGELOG.md +11 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +12 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -22
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/db/replication.d.ts +0 -5
- package/dist/storage/db/replication.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 1.15.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed ClickHouse replication initialization rejecting pre-existing tables that use local engines. Initialization now warns that `CREATE TABLE IF NOT EXISTS` will leave those tables unchanged and continues creating any missing replicated tables. ([#21538](https://github.com/mastra-ai/mastra/pull/21538))
|
|
8
|
+
|
|
9
|
+
- Fixed Studio metrics and logs detection for ClickHouse observability storage. Fixes #21435. ([#21536](https://github.com/mastra-ai/mastra/pull/21536))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378)]:
|
|
12
|
+
- @mastra/core@1.60.0-alpha.2
|
|
13
|
+
|
|
3
14
|
## 1.15.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -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.15.
|
|
6
|
+
version: "1.15.2-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -166,17 +166,6 @@ function rewriteEngineClauses(sql, replication) {
|
|
|
166
166
|
function applyReplicationToDDL(sql, replication) {
|
|
167
167
|
return addOnClusterToDDL(replication ? rewriteEngineClauses(sql, replication) : sql, replication);
|
|
168
168
|
}
|
|
169
|
-
function buildLocalTableReplicationError(tables) {
|
|
170
|
-
const tableList = tables.map((table) => ` - ${table.name} (${table.engine})`).join("\n");
|
|
171
|
-
return new _mastra_core_error.MastraError({
|
|
172
|
-
id: (0, _mastra_core_storage.createStorageErrorId)("CLICKHOUSE", "REPLICATION", "LOCAL_TABLES_UNSUPPORTED"),
|
|
173
|
-
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
174
|
-
category: _mastra_core_error.ErrorCategory.USER,
|
|
175
|
-
text: `ClickHouse replication is enabled, but existing Mastra tables use non-replicated local engines.
|
|
176
|
-
Mastra will not automatically convert existing local tables to replicated tables.
|
|
177
|
-
Please migrate or recreate these tables manually before enabling replication:\n${tableList}`
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
169
|
//#endregion
|
|
181
170
|
//#region src/storage/db/utils.ts
|
|
182
171
|
const TABLE_ENGINES = {
|
|
@@ -351,12 +340,12 @@ var ClickhouseDB = class extends _mastra_core_base.MastraBase {
|
|
|
351
340
|
}
|
|
352
341
|
async assertExistingTableCompatibleWithReplication(tableName) {
|
|
353
342
|
if (!isReplicationConfigured(this.replication)) return;
|
|
354
|
-
const
|
|
343
|
+
const localTable = (await (await this.client.query({
|
|
355
344
|
query: `SELECT name, engine FROM system.tables WHERE database = currentDatabase() AND name = {tableName:String}`,
|
|
356
345
|
query_params: { tableName },
|
|
357
346
|
format: "JSONEachRow"
|
|
358
|
-
})).json()).
|
|
359
|
-
if (
|
|
347
|
+
})).json()).find((row) => row.engine && !isReplicatedOrSharedEngine(row.engine));
|
|
348
|
+
if (localTable) this.logger.warn(`ClickHouse replication is enabled, but pre-existing table '${localTable.name}' uses local engine '${localTable.engine}'. CREATE TABLE IF NOT EXISTS will leave the existing table untouched.`);
|
|
360
349
|
}
|
|
361
350
|
/**
|
|
362
351
|
* Gets the sorting key (ORDER BY columns) for a table.
|
|
@@ -7032,17 +7021,14 @@ async function filterAppliedRetention(client, entries) {
|
|
|
7032
7021
|
* Silently returns if `system.tables` can't be queried — the rest of init
|
|
7033
7022
|
* will still run and leave any existing tables untouched.
|
|
7034
7023
|
*/
|
|
7035
|
-
async function assertExistingTablesCompatibleWithReplication(client, replication) {
|
|
7024
|
+
async function assertExistingTablesCompatibleWithReplication(client, replication, logger) {
|
|
7036
7025
|
if (!isReplicationConfigured(replication)) return;
|
|
7037
7026
|
const localTable = (await (await client.query({
|
|
7038
7027
|
query: `SELECT name, engine FROM system.tables WHERE database = currentDatabase() AND name IN ({tables:Array(String)})`,
|
|
7039
7028
|
query_params: { tables: [...ALL_TABLE_NAMES] },
|
|
7040
7029
|
format: "JSONEachRow"
|
|
7041
7030
|
})).json()).find((row) => !isReplicatedOrSharedEngine(row.engine));
|
|
7042
|
-
if (localTable)
|
|
7043
|
-
name: localTable.name,
|
|
7044
|
-
engine: localTable.engine
|
|
7045
|
-
}]);
|
|
7031
|
+
if (localTable) logger.warn(`ClickHouse replication is enabled, but pre-existing observability table '${localTable.name}' uses local engine '${localTable.engine}'. CREATE TABLE IF NOT EXISTS will leave existing tables untouched.`);
|
|
7046
7032
|
}
|
|
7047
7033
|
async function reconcileDiscoveryTables(client, replication) {
|
|
7048
7034
|
let engines;
|
|
@@ -7161,7 +7147,7 @@ var ObservabilityStorageClickhouseVNext = class extends _mastra_core_storage.Obs
|
|
|
7161
7147
|
if ((await checkLegacySpanMigrationStatus(this.#client)).needsMigration) this.logger?.warn?.("Legacy span table 'mastra_ai_spans' detected. Run 'npx mastra migrate' to migrate historical spans to the v-next schema.");
|
|
7162
7148
|
} catch {}
|
|
7163
7149
|
try {
|
|
7164
|
-
await assertExistingTablesCompatibleWithReplication(this.#client, this.#replication);
|
|
7150
|
+
await assertExistingTablesCompatibleWithReplication(this.#client, this.#replication, this.logger);
|
|
7165
7151
|
const existingStrategy = await detectExistingDeltaCursorStrategy(this.#client);
|
|
7166
7152
|
if (existingStrategy === "mixed") {
|
|
7167
7153
|
this.#deltaCursorStrategy = null;
|
|
@@ -7245,8 +7231,12 @@ var ObservabilityStorageClickhouseVNext = class extends _mastra_core_storage.Obs
|
|
|
7245
7231
|
};
|
|
7246
7232
|
}
|
|
7247
7233
|
getFeatures() {
|
|
7248
|
-
if (!deltaPollingSupported(this.#deltaCursorStrategy)) return;
|
|
7249
|
-
return [
|
|
7234
|
+
if (!deltaPollingSupported(this.#deltaCursorStrategy)) return ["metrics", "logs"];
|
|
7235
|
+
return [
|
|
7236
|
+
"metrics",
|
|
7237
|
+
"logs",
|
|
7238
|
+
"delta-polling"
|
|
7239
|
+
];
|
|
7250
7240
|
}
|
|
7251
7241
|
async createSpan(args) {
|
|
7252
7242
|
try {
|