mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-04 10:52:13 +02:00
* feat(connector): add Amazon Athena connector via Glue Data Catalog * fix(athena): address reviewer feedback * fix(athena): wire scope discovery, fix normalizeDriver, tighten types and tests * fix(athena): honor databases scope, wire sql-analysis dialect, harden config resolution - introspect() limits to the configured `databases` scope instead of scanning every Glue database in the account (docs promised this; connector ignored it) - add athena -> athena to sql-analysis SQLGLOT_DIALECTS so `ktx sql` and MCP read-only validation parse Athena SQL under the Trino grammar, not postgres - stringConfigValue coerces a resolved-empty `env:` reference to undefined so optional fields fall back to their defaults (workgroup 'primary', catalog 'AwsDataCatalog') instead of '' - drop trailing whitespace in dialect.test.ts * fix(athena): integrate with main's SQL/non-SQL dialect split and add dialect notes Rebase onto main, which introduced the KtxDialect (core) vs KtxSqlDialect (SQL-only) split for MongoDB: - KtxAthenaDialect implements KtxSqlDialect; the connector resolves it via getSqlDialectForDriver so SQL-generation methods stay in scope - add authored athena.md SQL notes for the sql_dialect_notes MCP tool, required now that athena resolves to the athena sqlglot dialect (dialect-notes coverage is derived from the warehouse-driver registry) --------- Co-authored-by: Andrey Avtomonov <andreybavt@gmail.com>
30 lines
1.5 KiB
TypeScript
30 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { sqlAnalysisDialectForDriver } from '../../../src/context/sql-analysis/dialect.js';
|
|
|
|
describe('sqlAnalysisDialectForDriver', () => {
|
|
it('maps ktx.yaml driver names to sqlglot dialects', () => {
|
|
expect(sqlAnalysisDialectForDriver('postgres')).toBe('postgres');
|
|
expect(sqlAnalysisDialectForDriver('bigquery')).toBe('bigquery');
|
|
expect(sqlAnalysisDialectForDriver('snowflake')).toBe('snowflake');
|
|
expect(sqlAnalysisDialectForDriver('mysql')).toBe('mysql');
|
|
expect(sqlAnalysisDialectForDriver('sqlserver')).toBe('tsql');
|
|
expect(sqlAnalysisDialectForDriver('sqlite')).toBe('sqlite');
|
|
expect(sqlAnalysisDialectForDriver('duckdb')).toBe('duckdb');
|
|
expect(sqlAnalysisDialectForDriver('clickhouse')).toBe('clickhouse');
|
|
expect(sqlAnalysisDialectForDriver('databricks')).toBe('databricks');
|
|
expect(sqlAnalysisDialectForDriver('athena')).toBe('athena');
|
|
});
|
|
|
|
it('maps local connection-type spellings to sqlglot dialects', () => {
|
|
expect(sqlAnalysisDialectForDriver('POSTGRESQL')).toBe('postgres');
|
|
expect(sqlAnalysisDialectForDriver('SQLSERVER')).toBe('tsql');
|
|
expect(sqlAnalysisDialectForDriver('BIGQUERY')).toBe('bigquery');
|
|
expect(sqlAnalysisDialectForDriver('SQLITE')).toBe('sqlite');
|
|
});
|
|
|
|
it('defaults to postgres for unknown or missing drivers', () => {
|
|
expect(sqlAnalysisDialectForDriver(undefined)).toBe('postgres');
|
|
expect(sqlAnalysisDialectForDriver('')).toBe('postgres');
|
|
expect(sqlAnalysisDialectForDriver('unknown')).toBe('postgres');
|
|
});
|
|
});
|