diff --git a/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.test.ts b/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.test.ts index 75db8644..9d5785cb 100644 --- a/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.test.ts +++ b/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.test.ts @@ -33,7 +33,7 @@ describe('BigQueryHistoricSqlQueryHistoryReader', () => { const client = queryClient([{ headers: ['1'], rows: [[1]], totalRows: 1 }]); const reader = new BigQueryHistoricSqlQueryHistoryReader({ projectId: 'project-1', region: 'US' }); - await expect(reader.probe(client)).resolves.toBeUndefined(); + await expect(reader.probe(client)).resolves.toEqual({ warnings: [], info: [] }); expect(client.executeQuery).toHaveBeenCalledWith( 'SELECT 1 FROM `project-1.region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT` LIMIT 1', diff --git a/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.ts b/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.ts index 1d3265be..e24c50cf 100644 --- a/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.ts +++ b/packages/context/src/ingest/adapters/historic-sql/bigquery-query-history-reader.ts @@ -195,7 +195,7 @@ export class BigQueryHistoricSqlQueryHistoryReader { this.viewPath = `\`${projectId}.region-${region}.INFORMATION_SCHEMA.JOBS_BY_PROJECT\``; } - async probe(client: unknown): Promise { + async probe(client: unknown): Promise<{ warnings: string[]; info: string[] }> { let result: QueryResultLike; try { result = await queryClient(client).executeQuery(`SELECT 1 FROM ${this.viewPath} LIMIT 1`); @@ -205,6 +205,7 @@ export class BigQueryHistoricSqlQueryHistoryReader { if (result.error) { throw grantsError(result.error); } + return { warnings: [], info: [] }; } async *fetchAggregated( diff --git a/packages/context/src/ingest/adapters/historic-sql/historic-sql.adapter.test.ts b/packages/context/src/ingest/adapters/historic-sql/historic-sql.adapter.test.ts index b388f71e..ddc63ded 100644 --- a/packages/context/src/ingest/adapters/historic-sql/historic-sql.adapter.test.ts +++ b/packages/context/src/ingest/adapters/historic-sql/historic-sql.adapter.test.ts @@ -22,7 +22,7 @@ const sqlAnalysis: SqlAnalysisPort = { const reader: HistoricSqlReader = { async probe() { - return { warnings: [] }; + return { warnings: [], info: [] }; }, async *fetchAggregated() {}, }; @@ -42,7 +42,7 @@ describe('HistoricSqlSourceAdapter', () => { const stagedDir = await tempDir(); const aggregateReader: HistoricSqlReader = { async probe() { - return { warnings: [] }; + return { warnings: [], info: [] }; }, async *fetchAggregated() { yield { diff --git a/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.test.ts b/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.test.ts index e347b534..3bf4b2f5 100644 --- a/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.test.ts +++ b/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.test.ts @@ -52,6 +52,7 @@ describe('PostgresPgssReader aggregate path', () => { await expect(reader.probe(client)).resolves.toEqual({ pgServerVersion: 'PostgreSQL 16.4 on x86_64-apple-darwin', warnings: [], + info: [], }); expect(executedSql(client, 0)).toContain("current_setting('server_version_num')::int"); @@ -159,10 +160,11 @@ describe('PostgresPgssReader aggregate path', () => { warnings: [ "pg_stat_statements.track is none; set it to top or all in the Postgres parameter group or config", ], + info: [], }); }); - it('warns when pg_stat_statements.max is below the recommended floor', async () => { + it('returns an info note when pg_stat_statements.max is below the recommended floor', async () => { const client = queryClient([ { headers: ['server_version_num', 'server_version'], @@ -177,7 +179,8 @@ describe('PostgresPgssReader aggregate path', () => { await expect(reader.probe(client)).resolves.toEqual({ pgServerVersion: 'PostgreSQL 16.4', - warnings: [ + warnings: [], + info: [ 'pg_stat_statements.max is 1000; set it to at least 5000 to reduce query-template eviction churn', ], }); diff --git a/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.ts b/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.ts index ec4d6679..8887acb8 100644 --- a/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.ts +++ b/packages/context/src/ingest/adapters/historic-sql/postgres-pgss-reader.ts @@ -247,16 +247,17 @@ export class PostgresPgssReader { const pgssMax = nullableInteger(value(maxRow, maxHeaders, 'max')); const warnings: string[] = []; + const info: string[] = []; if (track === 'none') { warnings.push('pg_stat_statements.track is none; set it to top or all in the Postgres parameter group or config'); } if (pgssMax !== null && pgssMax < RECOMMENDED_PGSS_MAX) { - warnings.push( + info.push( `pg_stat_statements.max is ${pgssMax}; set it to at least ${RECOMMENDED_PGSS_MAX} to reduce query-template eviction churn`, ); } - return { pgServerVersion, warnings }; + return { pgServerVersion, warnings, info }; } async *fetchAggregated( diff --git a/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.test.ts b/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.test.ts index 8b9c5fee..a3288223 100644 --- a/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.test.ts +++ b/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.test.ts @@ -33,7 +33,7 @@ describe('SnowflakeHistoricSqlQueryHistoryReader', () => { const client = queryClient([{ headers: ['1'], rows: [[1]], totalRows: 1 }]); const reader = new SnowflakeHistoricSqlQueryHistoryReader(); - await expect(reader.probe(client)).resolves.toBeUndefined(); + await expect(reader.probe(client)).resolves.toEqual({ warnings: [], info: [] }); expect(client.executeQuery).toHaveBeenCalledWith( 'SELECT 1 FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY LIMIT 1', diff --git a/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.ts b/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.ts index 4d8417b8..539df3c3 100644 --- a/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.ts +++ b/packages/context/src/ingest/adapters/historic-sql/snowflake-query-history-reader.ts @@ -169,7 +169,7 @@ function mapAggregatedRow(row: unknown[], indexes: Map): Aggrega } export class SnowflakeHistoricSqlQueryHistoryReader { - async probe(client: unknown): Promise { + async probe(client: unknown): Promise<{ warnings: string[]; info: string[] }> { let result: QueryResultLike; try { result = await queryClient(client).executeQuery(PROBE_SQL); @@ -179,6 +179,7 @@ export class SnowflakeHistoricSqlQueryHistoryReader { if (result.error) { throw grantsError(result.error); } + return { warnings: [], info: [] }; } async *fetchAggregated( diff --git a/packages/context/src/ingest/adapters/historic-sql/stage-unified.test.ts b/packages/context/src/ingest/adapters/historic-sql/stage-unified.test.ts index f9d60fce..c946f597 100644 --- a/packages/context/src/ingest/adapters/historic-sql/stage-unified.test.ts +++ b/packages/context/src/ingest/adapters/historic-sql/stage-unified.test.ts @@ -38,7 +38,7 @@ describe('stageHistoricSqlAggregatedSnapshot', () => { const stagedDir = await tempDir(); const reader: HistoricSqlReader = { async probe() { - return { warnings: ['pg_stat_statements.max is low; aggregation still proceeds'] }; + return { warnings: ['pg_stat_statements.track is none; aggregation still proceeds'], info: [] }; }, async *fetchAggregated() { yield aggregate({ @@ -123,7 +123,7 @@ describe('stageHistoricSqlAggregatedSnapshot', () => { touchedTableCount: 2, parseFailures: 1, warnings: ['parse_failed:bad-parse'], - probeWarnings: ['pg_stat_statements.max is low; aggregation still proceeds'], + probeWarnings: ['pg_stat_statements.track is none; aggregation still proceeds'], staleArchiveAfterDays: 90, }); diff --git a/packages/context/src/ingest/adapters/historic-sql/types.ts b/packages/context/src/ingest/adapters/historic-sql/types.ts index d8c5c364..a827e8ae 100644 --- a/packages/context/src/ingest/adapters/historic-sql/types.ts +++ b/packages/context/src/ingest/adapters/historic-sql/types.ts @@ -126,6 +126,7 @@ export type StagedManifest = z.infer; export interface HistoricSqlProbeResult { warnings: string[]; + info?: string[]; } export interface HistoricSqlReader { @@ -146,9 +147,10 @@ export interface KtxPostgresQueryClient { executeQuery(sql: string, params?: unknown[]): Promise<{ headers: string[]; rows: unknown[][]; totalRows?: number }>; } -export interface PostgresPgssProbeResult { +export interface PostgresPgssProbeResult extends HistoricSqlProbeResult { pgServerVersion: string; warnings: string[]; + info: string[]; } export interface HistoricSqlSourceAdapterDeps {