Skip to content

test: add SQL validation e2e test suite via EXPLAIN AST#83

Merged
KeKs0r merged 2 commits intomainfrom
marc/clickhouse-sql-validate
Mar 2, 2026
Merged

test: add SQL validation e2e test suite via EXPLAIN AST#83
KeKs0r merged 2 commits intomainfrom
marc/clickhouse-sql-validate

Conversation

@KeKs0r
Copy link
Contributor

@KeKs0r KeKs0r commented Mar 2, 2026

Summary

Adds comprehensive e2e test suite for SQL generation validation. All generated SQL (CREATE TABLE/VIEW/MV, ALTER operations, migration plans) is validated via ClickHouse's EXPLAIN AST parser — catching malformed SQL, bad quoting, missing clauses without executing any DDL.

Coverage: 80+ test cases — primitive types, parameterized types, complex/nested types, defaults, comments, nullable columns, all 6 MergeTree engine variants, PARTITION BY expressions, ORDER BY/PRIMARY KEY, TTL, SETTINGS, all 5 skip index types, projections, table comments, reserved word column names, deeply nested types, and full migration plan diffs.

Test plan

  • Verify bun run build passes (no circular dependency)
  • Verify bun run typecheck passes
  • Verify bun run lint passes on modified packages
  • Verify existing tests still pass

🤖 Generated with Claude Code

KeKs0r and others added 2 commits March 2, 2026 15:07
Validates that all generated SQL (CREATE, ALTER, migration plans) is syntactically valid ClickHouse SQL. Uses ClickHouse's EXPLAIN AST to parse SQL without executing DDL. Comprehensive coverage: 80+ test cases covering primitive/parameterized/complex types, defaults, comments, all engine families, indexes, projections, TTL, settings, views, and migration plans.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
toCreateSQL runs assertValidDefinitions which rejects expressions like
toDate(created_at) in orderBy. Use raw SQL for this edge case to test
ClickHouse parsing without hitting the schema validator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@KeKs0r KeKs0r merged commit 4de2939 into main Mar 2, 2026
2 checks passed
@KeKs0r KeKs0r deleted the marc/clickhouse-sql-validate branch March 2, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant