Skip to content

Conversation

@kyleconroy
Copy link
Collaborator

When SETTINGS comes after FORMAT in a query (e.g., "SELECT * FORMAT Null SETTINGS..."),
the Set node should only appear at the SelectWithUnionQuery level, not at the
SelectQuery level. This matches ClickHouse's EXPLAIN AST behavior.

Added SettingsAfterFormat field to SelectQuery AST to track this ordering.

This fixes 156+ explain tests that were previously failing.

When SETTINGS comes after FORMAT in a query (e.g., "SELECT * FORMAT Null SETTINGS..."),
the Set node should only appear at the SelectWithUnionQuery level, not at the
SelectQuery level. This matches ClickHouse's EXPLAIN AST behavior.

Added SettingsAfterFormat field to SelectQuery AST to track this ordering.

This fixes 156+ explain tests that were previously failing.
When SETTINGS comes after FORMAT and there's a FROM clause,
Set should appear at both SelectQuery and SelectWithUnionQuery levels.
When there's no FROM clause, Set only appears at SelectWithUnionQuery level.

This fixes ~87 more explain tests.
When INSERT has a column list (e.g., INSERT INTO t (col1, col2) SELECT ...),
the columns are now output as an ExpressionList child node.
Implemented support for:
- ADD PROJECTION (parses projection definition with SELECT/ORDER BY/GROUP BY)
- DROP PROJECTION
- MATERIALIZE PROJECTION
- CLEAR PROJECTION

Added new AST types:
- Projection (with name and select query)
- ProjectionSelectQuery (with columns, order by, group by)

This fixes 53+ explain tests related to ALTER TABLE projections.
Reverted SETTINGS placement logic to the original behavior:
- SETTINGS at SelectQuery level only when there's NO FORMAT
- SETTINGS at SelectWithUnionQuery level only when there IS FORMAT

The previous changes incorrectly added SettingsAfterFormat tracking
which caused tests to fail. The original simpler logic is correct.

Also restored all metadata.json files to their original state.
- Updated CLAUDE.md to emphasize running check-explain after changes
- Ran check-explain which updated 131 metadata.json files
- Tests now properly track which explain tests pass with PROJECTION support
@kyleconroy kyleconroy merged commit 7d6c71e into main Dec 28, 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