From f327b815ed0b09755748c97d2caa64d9fe448975 Mon Sep 17 00:00:00 2001 From: JeremyFunk Date: Wed, 19 Aug 2026 23:01:38 +0200 Subject: [PATCH] test(api): run the integration SQL catalog through the ClickHouse e2e sweep MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit collectIntegrationCatalog() was only consumed by the integrations package's own unit tests, so the Cloudflare/PlanetScale/AI fixtures never met the real analyzer — while a comment in catalog.ts claimed the sweep's 64-bit decode assertion covered them. Append the integration catalog to the sweep's entry list (both catalogs satisfy the same structural shape) and document the wiring in catalog.ts, making that claim true. Co-Authored-By: Claude Fable 5 --- .../sql-catalog.clickhouse.e2e.test.ts | 26 +++++++++++++++++-- .../query-engine-integrations/src/catalog.ts | 4 ++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/apps/api/src/services/warehouse/sql-catalog.clickhouse.e2e.test.ts b/apps/api/src/services/warehouse/sql-catalog.clickhouse.e2e.test.ts index d0121e7ec..ef4c11a2f 100644 --- a/apps/api/src/services/warehouse/sql-catalog.clickhouse.e2e.test.ts +++ b/apps/api/src/services/warehouse/sql-catalog.clickhouse.e2e.test.ts @@ -9,11 +9,18 @@ // `DESCRIBE (SELECT …)` type-checks without reading a row, so this is cheap: // ~80 unique shapes, a few seconds on top of a job that already boots the // server and replays the migrations. +// +// Covers both catalogs: `@maple/query-engine`'s own (pipes, query specs, core +// builders) and `@maple/query-engine-integrations`' (Cloudflare, PlanetScale, +// AI builders), which lives with those builders because the core package must +// not depend on the integrations package. import { afterAll, assert, beforeAll, describe, it } from "@effect/vitest" import { Effect } from "effect" +import type { CompiledQuery } from "@maple/query-engine/ch" import { collectSqlCatalog, dedupeByFingerprint } from "@maple/query-engine/sql-catalog" import { normalizeSqlForClickHouseClient } from "@maple/query-engine/execution" +import { collectIntegrationCatalog } from "@maple/query-engine-integrations/catalog" import { applyRealMigrations, clickhouseE2eEnabled, @@ -35,8 +42,23 @@ const IDENTITY_COLUMN_ALLOWLIST: ReadonlySet = new Set([]) const database = uniqueDatabase("maple_sql_catalog_e2e") -/** Deduped so N fixtures over one shape cost one analyzer round trip. */ -const catalog = dedupeByFingerprint(collectSqlCatalog()) +/** The subset of a catalog entry the sweep reads — the core and integration + * catalogs are separate types (`@maple/query-engine` must not import the + * integrations package), but both satisfy this shape. */ +interface SweepEntry { + readonly id: string + readonly sql: string + readonly compiled?: CompiledQuery + readonly sampleValues?: Readonly> +} + +/** Core catalog deduped so N fixtures over one shape cost one analyzer round + * trip; the integration catalog has no fingerprints and every fixture is a + * distinct shape, so it is appended as-is. */ +const catalog: ReadonlyArray = [ + ...dedupeByFingerprint(collectSqlCatalog()), + ...collectIntegrationCatalog(), +] describe.skipIf(!clickhouseE2eEnabled)("SQL catalog analyzer sweep", () => { beforeAll(async () => { diff --git a/packages/query-engine-integrations/src/catalog.ts b/packages/query-engine-integrations/src/catalog.ts index 1f6483313..069fea60a 100644 --- a/packages/query-engine-integrations/src/catalog.ts +++ b/packages/query-engine-integrations/src/catalog.ts @@ -4,7 +4,9 @@ // import this package (the dependency runs one way), so the fixtures live with // the builders instead. Same contract as the core catalog — compile the REAL // exported builder with production-shaped params, so every SQL shape the -// product can emit is enumerated and snapshotted. +// product can emit is enumerated and snapshotted. The ClickHouse e2e sweep in +// apps/api (`sql-catalog.clickhouse.e2e.test.ts`) analyzes these fixtures +// against the real migrations alongside the core catalog. import { compile, compileUnion, type CompiledQuery } from "@maple/query-engine/ch" import * as CH from "./index"