Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions apps/api/src/services/warehouse/sql-catalog.clickhouse.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -35,8 +42,23 @@ const IDENTITY_COLUMN_ALLOWLIST: ReadonlySet<string> = 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<unknown>
readonly sampleValues?: Readonly<Record<string, unknown>>
}

/** 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<SweepEntry> = [
...dedupeByFingerprint(collectSqlCatalog()),
...collectIntegrationCatalog(),
]

describe.skipIf(!clickhouseE2eEnabled)("SQL catalog analyzer sweep", () => {
beforeAll(async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/query-engine-integrations/src/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading