Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

This significantly improves test coverage by adding explain output handling for:

  • CastExpr (CAST and :: operator)
  • InExpr (IN and NOT IN expressions)
  • TernaryExpr (ternary conditional)
  • ArrayAccess (array element access)
  • TupleAccess (tuple element access)
  • DropQuery (DROP TABLE/VIEW/DATABASE)
  • LikeExpr (LIKE/ILIKE expressions)
  • BetweenExpr (BETWEEN expressions)
  • IsNullExpr (IS NULL/IS NOT NULL)
  • CaseExpr (CASE WHEN expressions)
  • IntervalExpr (INTERVAL expressions)
  • ExistsExpr (EXISTS subqueries)
  • ExtractExpr (EXTRACT function)
  • CreateQuery (CREATE TABLE/VIEW/DATABASE)
  • SystemQuery (SYSTEM commands)
  • ExplainQuery (EXPLAIN statements)
  • ShowQuery (SHOW statements)
  • UseQuery (USE database)
  • DescribeQuery (DESCRIBE/DESC)
  • TableJoin (JOIN clauses)
  • DataType (type expressions)
  • Parameter (query parameters)

Also fixes:

  • ARRAY JOIN placement in TablesInSelectQuery
  • Subquery alias handling in TableExpression
  • SETTINGS clause output as Set
  • Tuple literals with complex expressions rendered as Function tuple

Tests improved from ~50% to ~73% passing (4998 of 6824).

This significantly improves test coverage by adding explain output handling for:

- CastExpr (CAST and :: operator)
- InExpr (IN and NOT IN expressions)
- TernaryExpr (ternary conditional)
- ArrayAccess (array element access)
- TupleAccess (tuple element access)
- DropQuery (DROP TABLE/VIEW/DATABASE)
- LikeExpr (LIKE/ILIKE expressions)
- BetweenExpr (BETWEEN expressions)
- IsNullExpr (IS NULL/IS NOT NULL)
- CaseExpr (CASE WHEN expressions)
- IntervalExpr (INTERVAL expressions)
- ExistsExpr (EXISTS subqueries)
- ExtractExpr (EXTRACT function)
- CreateQuery (CREATE TABLE/VIEW/DATABASE)
- SystemQuery (SYSTEM commands)
- ExplainQuery (EXPLAIN statements)
- ShowQuery (SHOW statements)
- UseQuery (USE database)
- DescribeQuery (DESCRIBE/DESC)
- TableJoin (JOIN clauses)
- DataType (type expressions)
- Parameter (query parameters)

Also fixes:
- ARRAY JOIN placement in TablesInSelectQuery
- Subquery alias handling in TableExpression
- SETTINGS clause output as Set
- Tuple literals with complex expressions rendered as Function tuple

Tests improved from ~50% to ~73% passing (4998 of 6824).
- Handle empty tuples (nil arguments) as Function tuple with empty ExpressionList
- Add array handling for complex expressions (renders as Function array)
- Normalize function names (ltrim -> trimLeft, etc.)
- Fix ShowQuery capitalization
- Fix SystemQuery format to "SYSTEM query"

Tests improved from ~73% to ~74% passing (5057 of 6824).
Reorganize the explain functionality into a dedicated internal package
with separate files for each category of AST types:

- internal/explain/explain.go - main Explain function and core dispatcher
- internal/explain/select.go - SelectQuery and related types
- internal/explain/expressions.go - expressions (Literal, BinaryExpr, etc.)
- internal/explain/functions.go - FunctionCall, Lambda, CAST, IN, etc.
- internal/explain/tables.go - table-related types
- internal/explain/statements.go - DDL statements (Create, Drop, etc.)
- internal/explain/format.go - formatting and normalization functions

The parser package now delegates to the internal package.

No functional changes - all 5057 tests still pass.
Add support for rendering empty arrays as Function array with empty
ExpressionList, matching ClickHouse's EXPLAIN AST format.

Tests improved from ~74% to ~74.3% passing (5072 of 6824).
When an engine has parentheses (like MergeTree()), output it with
children count and empty ExpressionList, matching ClickHouse's format.

Tests improved to 5090 passing (~74.6% of 6824).
- Add DROP USER support with proper 'DROP USER query' output format
- Add SHOW FUNCTIONS type handling with 'ShowFunctions' output
- Fix cast shorthand (::) to output expression as string literal
- Escape backslashes in string literals for proper output
- Add ENGINE function parameters output in CREATE TABLE
- Add SETTINGS output (Set) in CREATE TABLE storage definition
- Remove Subquery wrapper for AS SELECT in CREATE TABLE

Tests passing: 5128 (up from 5090)
- Change NULL literal output from 'Null' to 'NULL' (uppercase)
- Fix DataType with complex parameters (like Enum) to output as
  children with ExpressionList instead of formatted string
- Update Column function to use Node() for type output

Tests passing: 5179 (up from 5128)
- Check if any SelectQuery in the union has a Format field
- Output Format Identifier at SelectWithUnionQuery level (matches ClickHouse)
- Update child count accordingly

Tests passing: 5197 (up from 5179)
@kyleconroy kyleconroy merged commit b22df7b into main Dec 13, 2025
1 check passed
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.

3 participants