Commit 7d6c71e
Fix SETTINGS placement in EXPLAIN AST for FORMAT...SETTINGS syntax (#73)
* Fix SETTINGS placement in EXPLAIN AST for FORMAT...SETTINGS syntax
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.
* Handle SETTINGS placement edge case for FROM clause presence
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.
* Add column list output to InsertQuery EXPLAIN
When INSERT has a column list (e.g., INSERT INTO t (col1, col2) SELECT ...),
the columns are now output as an ExpressionList child node.
* Add PROJECTION support for ALTER commands
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.
* Fix SETTINGS placement regression - revert to original logic
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.
* Update CLAUDE.md and run check-explain to update metadata
- 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
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4821721 commit 7d6c71e
File tree
136 files changed
+378
-513
lines changed- ast
- internal/explain
- parser
- testdata
- 00071_merge_tree_optimize_aio
- 00152_insert_different_granularity
- 00160_merge_and_index_in_in
- 00180_attach_materialized_view
- 00191_aggregating_merge_tree_and_final
- 00193_parallel_replicas
- 00226_zookeeper_deduplication_and_unexpected_parts_long
- 00276_sample
- 00278_insert_already_sorted
- 00282_merging
- 00311_array_primary_key
- 00314_sample_factor_virtual_column
- 00395_nullable
- 00432_aggregate_function_scalars_and_constants
- 00542_access_to_temporary_table_in_readonly_mode
- 00561_storage_join
- 00579_virtual_column_and_lazy
- 00632_get_sample_block_cache
- 00688_low_cardinality_alter_add_column
- 00688_low_cardinality_serialization
- 00700_decimal_aggregates
- 00700_decimal_in_keys
- 00717_low_cardinaliry_distributed_group_by
- 00751_low_cardinality_nullable_group_by
- 00753_comment_columns_zookeeper
- 00754_alter_modify_column_partitions
- 00760_insert_json_with_defaults
- 00863_comma_join_in
- 00875_join_right_nulls
- 00927_asof_join_long
- 01014_count_of_merges_metrics
- 01080_engine_merge_prewhere_tupleelement_error
- 01099_parallel_distributed_insert_select
- 01165_lost_part_empty_partition
- 01230_join_get_truncate
- 01286_constraints_on_default
- 01307_bloom_filter_index_string_multi_granulas
- 01430_modify_sample_by_zookeeper_long
- 01441_low_cardinality_array_index
- 01490_nullable_string_to_enum
- 01511_prewhere_with_virtuals
- 01514_parallel_formatting
- 01576_alias_column_rewrite
- 01603_decimal_mult_float
- 01651_lc_insert_tiny_log_1
- 01651_lc_insert_tiny_log_2
- 01651_lc_insert_tiny_log_3
- 01701_clear_projection_and_part_remove
- 01710_aggregate_projection_with_hashing
- 01710_normal_projection_fix1
- 01710_normal_projection_join_plan_fix
- 01710_order_by_projections_incomplete
- 01710_projection_drop_if_exists
- 01710_projection_fetch_long
- 01710_projection_materialize_with_missing_columns
- 01710_projection_optimize_materialize
- 01710_projection_query_plan_optimization_misc
- 01710_projection_vertical_merges
- 01710_projection_with_mixed_pipeline
- 01710_projection_with_nullable_keys
- 01710_projections_order_by_incomplete
- 01798_uniq_theta_sketch
- 01798_uniq_theta_union_intersect_not
- 01846_null_as_default_for_insert_select
- 02013_bloom_filter_hasAll
- 02100_alter_scalar_circular_deadlock
- 02245_weird_partitions_pruning
- 02267_empty_arrays_read_reverse
- 02317_distinct_in_order_optimization
- 02319_quantile_interpolated_weighted
- 02356_insert_query_log_metrics
- 02371_select_projection_normal_agg
- 02418_tautological_if_index
- 02458_key_condition_not_like_prefix
- 02516_projections_with_rollup
- 02763_mutate_compact_part_with_skip_indices_and_projections
- 02785_global_join_too_many_columns
- 02792_drop_projection_lwd
- 02811_read_in_order_and_array_join_bug
- 02833_array_join_columns
- 02842_largestTriangleThreeBuckets_aggregate_function
- 02862_sorted_distinct_sparse_fix
- 02903_bug_43644
- 02934_merge_tree_max_projections
- 02941_projections_external_aggregation
- 02971_limit_by_distributed
- 02989_join_using_parent_scope
- 02998_projection_after_attach_partition
- 02999_scalar_subqueries_bug_1
- 03001_insert_threads_deduplication
- 03033_index_definition_sql_udf_bug
- 03033_scalars_context_data_race
- 03100_lwu_33_add_column
- 03100_lwu_44_missing_default
- 03129_low_cardinality_nullable_non_first_primary_key
- 03174_projection_deduplicate
- 03206_projection_merge_special_mergetree
- 03214_count_distinct_null_key_memory_leak
- 03240_insert_select_named_tuple
- 03240_quantile_exact_weighted_interpolated
- 03244_skip_index_in_final_query_with_pk_rescan_no_final_mark
- 03252_fill_missed_arrays
- 03254_last_2_samples_aggregate_function_simple
- 03254_last_2_samples_aggregate_function
- 03261_delayed_streams_memory
- 03263_forbid_materialize_sort_key
- 03282_block_number_otehr_mutations
- 03311_subcolumns_in_default_and_materialized_expressions
- 03314_variant_rowbinary_file
- 03365_csv_time_deserialization_bug
- 03401_normal_projection_with_part_offset_no_sorting
- 03401_normal_projection_with_part_offset
- 03402_materialized_tuple_element
- 03459_numeric_indexed_vector_decode
- 03460_normal_projection_index
- 03464_projections_with_subcolumns
- 03513_lazy_materialization_projections_fix
- 03522_alter_modify_column_and_materialize_projection
- 03522_join_using_bug_78907
- 03560_parallel_replicas_external_aggregation
- 03560_parallel_replicas_memory_bound_merging_projection
- 03560_parallel_replicas_projection
- 03593_allow_projection_with_parent_part_offset
- 03629_storage_s3_disallow_index_alter
- 03651_positional_argument_agg_projection
- 03668_shard_join_in_reverse_order
- 03733_join_order_dp
- 03748_tuple_of_sparse_elements_bug
- 03749_materialized_view_not_supports_parallel_write
- 03755_final_prewhere_duplicate_columns
- 03758_positional_argument_agg_projection
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
136 files changed
+378
-513
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
425 | 426 | | |
426 | 427 | | |
427 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
428 | 449 | | |
429 | 450 | | |
430 | 451 | | |
| |||
456 | 477 | | |
457 | 478 | | |
458 | 479 | | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
469 | 494 | | |
470 | 495 | | |
471 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
54 | 50 | | |
55 | 51 | | |
56 | 52 | | |
| |||
126 | 122 | | |
127 | 123 | | |
128 | 124 | | |
129 | | - | |
| 125 | + | |
| 126 | + | |
130 | 127 | | |
131 | 128 | | |
132 | 129 | | |
| |||
235 | 232 | | |
236 | 233 | | |
237 | 234 | | |
238 | | - | |
239 | 235 | | |
240 | 236 | | |
241 | 237 | | |
242 | | - | |
243 | 238 | | |
244 | 239 | | |
245 | 240 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
253 | 246 | | |
254 | 247 | | |
255 | 248 | | |
| |||
390 | 383 | | |
391 | 384 | | |
392 | 385 | | |
393 | | - | |
394 | | - | |
| 386 | + | |
| 387 | + | |
395 | 388 | | |
396 | 389 | | |
397 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
| |||
672 | 683 | | |
673 | 684 | | |
674 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
675 | 694 | | |
676 | 695 | | |
677 | 696 | | |
678 | 697 | | |
679 | 698 | | |
680 | 699 | | |
681 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
682 | 741 | | |
683 | 742 | | |
684 | 743 | | |
| |||
743 | 802 | | |
744 | 803 | | |
745 | 804 | | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
746 | 813 | | |
747 | 814 | | |
748 | 815 | | |
| |||
0 commit comments