From 0ecea6e54839ce9c1d19a7a53e4c1ed02e424b99 Mon Sep 17 00:00:00 2001 From: Andrey Avtomonov <7889985+andreybavt@users.noreply.github.com> Date: Mon, 18 May 2026 18:12:31 +0200 Subject: [PATCH] fix(scan): bind connector sample methods and add duckdb aggregate dialect description-generation extracted sampleTable/sampleColumn as bare locals and called them without `this`, crashing every class-based connector with "Cannot read properties of undefined (reading 'assertConnection')" during deep ingest. Binding restores method context. relationship-profiling fell back to SQLite-flavored GROUP_CONCAT for any driver without an explicit branch, breaking DuckDB statistical validation with a parser error and stranding all proposals in review. Added a duckdb branch using STRING_AGG/CHR(31). --- packages/context/src/scan/description-generation.ts | 4 ++-- packages/context/src/scan/relationship-profiling.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/context/src/scan/description-generation.ts b/packages/context/src/scan/description-generation.ts index ba61fb62..f4ad2d35 100644 --- a/packages/context/src/scan/description-generation.ts +++ b/packages/context/src/scan/description-generation.ts @@ -457,7 +457,7 @@ export class KtxDescriptionGenerator { } } - const sampleTable = input.connector.sampleTable; + const sampleTable = input.connector.sampleTable?.bind(input.connector); let sampleData: KtxTableSampleResult | null = null; let fallbackReason: 'capability_missing' | 'sampling_failed' | 'empty_sample' | null = null; @@ -678,7 +678,7 @@ export class KtxDescriptionGenerator { }); columnValues = []; } else { - const sampleColumn = input.connector.sampleColumn; + const sampleColumn = input.connector.sampleColumn.bind(input.connector); try { const sample = await retryAsync( () => diff --git a/packages/context/src/scan/relationship-profiling.ts b/packages/context/src/scan/relationship-profiling.ts index fa6acfac..ac1e063e 100644 --- a/packages/context/src/scan/relationship-profiling.ts +++ b/packages/context/src/scan/relationship-profiling.ts @@ -214,6 +214,9 @@ function sampleAggregateSql(driver: KtxConnectionDriver, innerSql: string): stri if (driver === 'postgres') { return `(SELECT STRING_AGG(CAST(value AS TEXT), CHR(31)) FROM (${innerSql}) AS relationship_profile_values)`; } + if (driver === 'duckdb') { + return `(SELECT STRING_AGG(CAST(value AS VARCHAR), CHR(31)) FROM (${innerSql}) AS relationship_profile_values)`; + } if (driver === 'bigquery') { return `(SELECT STRING_AGG(CAST(value AS STRING), '\\u001F') FROM (${innerSql}) AS relationship_profile_values)`; }