@mastra/clickhouse 1.16.0-alpha.0 → 1.16.0-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 1.16.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed ClickHouse observability discovery refreshable materialized views failing with error 36 when their target tables use a Replicated engine inside a non-Replicated (Atomic) database. The discovery views now refresh in APPEND mode, and existing deployments with the old view definitions are migrated automatically on startup (only the views are recreated; discovery data is kept). Fixes https://github.com/mastra-ai/mastra/issues/21168 ([#22103](https://github.com/mastra-ai/mastra/pull/22103))
8
+
9
+ - Updated dependencies [[`2c85f42`](https://github.com/mastra-ai/mastra/commit/2c85f428e04ccd63ea31a7ec80b5b327afdad555), [`11bbeb9`](https://github.com/mastra-ai/mastra/commit/11bbeb9b108ef2264e05acefc6dafb9cbb342921), [`1a485f3`](https://github.com/mastra-ai/mastra/commit/1a485f3538f5ec64d58bd8b5e1e99de0c695c87b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`8661d7d`](https://github.com/mastra-ai/mastra/commit/8661d7d7179f0a024456aabdd8679bcecd09ac28), [`575e343`](https://github.com/mastra-ai/mastra/commit/575e343900451021d96110916497d334af7bc252), [`cacb839`](https://github.com/mastra-ai/mastra/commit/cacb8392d9e74189b56d857290b0615f98a2683d), [`b47b26e`](https://github.com/mastra-ai/mastra/commit/b47b26e6fe95cb8a3482be2c5e52de157fe59d0b), [`0d37487`](https://github.com/mastra-ai/mastra/commit/0d37487d9f349388a3f1cef6a536cf9dcc4b6273), [`c46eb09`](https://github.com/mastra-ai/mastra/commit/c46eb09ce4987509af57a0ac582c61241a6dd2f1), [`30ed33e`](https://github.com/mastra-ai/mastra/commit/30ed33ee14084a26019aba15fceadda6d6ddefaf), [`91ad69d`](https://github.com/mastra-ai/mastra/commit/91ad69d64994c89199b0c55399e64ed91c61df2f), [`8dc408d`](https://github.com/mastra-ai/mastra/commit/8dc408d34438f9e13297f792c11a5cfd6cf952e1), [`c92def1`](https://github.com/mastra-ai/mastra/commit/c92def10a13c822972c96f0a4ca6ffc1f4258aed), [`c5eaec5`](https://github.com/mastra-ai/mastra/commit/c5eaec5a860d80d0e3805e67db0414b87ac8cbed), [`e66b2ba`](https://github.com/mastra-ai/mastra/commit/e66b2ba100db63eaeab6e21e1ea34b113f2ec781)]:
10
+ - @mastra/core@1.62.0-alpha.3
11
+
3
12
  ## 1.16.0-alpha.0
4
13
 
5
14
  ### Minor Changes
@@ -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.16.0-alpha.0"
6
+ version: "1.16.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.16.0-alpha.0",
2
+ "version": "1.16.0-alpha.1",
3
3
  "package": "@mastra/clickhouse",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -3520,7 +3520,7 @@ function unionDistinctFromSignals(kind, key1Expr, valueExpr, extraJoin = "", ext
3520
3520
  }
3521
3521
  const DISCOVERY_VALUES_MV_DDL = `
3522
3522
  CREATE MATERIALIZED VIEW IF NOT EXISTS ${MV_DISCOVERY_VALUES}
3523
- REFRESH EVERY 1 MINUTE
3523
+ REFRESH EVERY 1 MINUTE APPEND
3524
3524
  TO ${TABLE_DISCOVERY_VALUES}
3525
3525
  AS
3526
3526
  SELECT DISTINCT kind, key1, value FROM (
@@ -3545,7 +3545,7 @@ SELECT DISTINCT kind, key1, value FROM (
3545
3545
  `;
3546
3546
  const DISCOVERY_PAIRS_MV_DDL = `
3547
3547
  CREATE MATERIALIZED VIEW IF NOT EXISTS ${MV_DISCOVERY_PAIRS}
3548
- REFRESH EVERY 5 MINUTE
3548
+ REFRESH EVERY 5 MINUTE APPEND
3549
3549
  TO ${TABLE_DISCOVERY_PAIRS}
3550
3550
  AS
3551
3551
  SELECT DISTINCT kind, key1, key2, value FROM (
@@ -7083,6 +7083,12 @@ async function filterAppliedRetention(client, entries) {
7083
7083
  * Init's subsequent `CREATE TABLE IF NOT EXISTS` and discovery MV bootstrap
7084
7084
  * recreate both with the current definitions.
7085
7085
  *
7086
+ * Separately, a refreshable MV whose stored definition lacks the `APPEND`
7087
+ * modifier (created by older releases) is dropped — keeping its target
7088
+ * table — so the MV bootstrap recreates it with the current APPEND
7089
+ * definition. Non-APPEND refreshes swap the target table atomically, which
7090
+ * fails when the target is Replicated inside a non-Replicated database.
7091
+ *
7086
7092
  * Silently returns if `system.tables` can't be queried — the rest of init
7087
7093
  * will still run and leave any existing tables untouched.
7088
7094
  */
@@ -7097,13 +7103,20 @@ async function assertExistingTablesCompatibleWithReplication(client, replication
7097
7103
  }
7098
7104
  async function reconcileDiscoveryTables(client, replication) {
7099
7105
  let engines;
7106
+ let mvCreateQueries;
7100
7107
  try {
7101
7108
  const rows = await (await client.query({
7102
- query: `SELECT name, engine FROM system.tables WHERE database = currentDatabase() AND name IN ({tables:Array(String)})`,
7103
- query_params: { tables: [TABLE_DISCOVERY_VALUES, TABLE_DISCOVERY_PAIRS] },
7109
+ query: `SELECT name, engine, create_table_query FROM system.tables WHERE database = currentDatabase() AND name IN ({tables:Array(String)})`,
7110
+ query_params: { tables: [
7111
+ TABLE_DISCOVERY_VALUES,
7112
+ TABLE_DISCOVERY_PAIRS,
7113
+ MV_DISCOVERY_VALUES,
7114
+ MV_DISCOVERY_PAIRS
7115
+ ] },
7104
7116
  format: "JSONEachRow"
7105
7117
  })).json();
7106
7118
  engines = new Map(rows.map((r) => [r.name, r.engine]));
7119
+ mvCreateQueries = new Map(rows.map((r) => [r.name, r.create_table_query]));
7107
7120
  } catch {
7108
7121
  return;
7109
7122
  }
@@ -7116,9 +7129,13 @@ async function reconcileDiscoveryTables(client, replication) {
7116
7129
  }];
7117
7130
  for (const { table, mv } of targets) {
7118
7131
  const engine = engines.get(table);
7119
- if (!engine || isReplacingMergeTreeEngine(engine)) continue;
7120
- await client.command({ query: addOnClusterToDDL(`DROP VIEW IF EXISTS ${mv}`, replication) });
7121
- await client.command({ query: addOnClusterToDDL(`DROP TABLE IF EXISTS ${table}`, replication) });
7132
+ if (engine && !isReplacingMergeTreeEngine(engine)) {
7133
+ await client.command({ query: addOnClusterToDDL(`DROP VIEW IF EXISTS ${mv}`, replication) });
7134
+ await client.command({ query: addOnClusterToDDL(`DROP TABLE IF EXISTS ${table}`, replication) });
7135
+ continue;
7136
+ }
7137
+ const createQuery = mvCreateQueries.get(mv);
7138
+ if (createQuery && /REFRESH EVERY/i.test(createQuery) && !/\bAPPEND\b/i.test(createQuery)) await client.command({ query: addOnClusterToDDL(`DROP VIEW IF EXISTS ${mv}`, replication) });
7122
7139
  }
7123
7140
  }
7124
7141
  async function queryNamesByTable(client, query, tables) {