Repository navigation
Fix AST formatting roundtrip for FROM and VALUES used as function names - #102338
Merged
Merged
Conversation
… names The BuzzHouse fuzzer found that when `FROM` or `VALUES` are used as function names, the AST formatter outputs them without backtick-quoting. When parsing the formatted query back, the parser interprets these as SQL clause keywords instead of function names, causing a SYNTAX_ERROR. Add `FROM` and `VALUES` to the list of keywords that must be backtick-quoted in `writeProbablyQuotedStringImpl`, alongside the existing `DISTINCT`, `ALL`, `TABLE`, and `SELECT` entries. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101054&sha=1a927fce3bc0eb606438ccc418daafbd3060ad2b&name_0=PR&name_1=BuzzHouse%20%28amd_debug%29
Contributor
|
Workflow [PR], commit [e0d8287] Summary: ✅ AI ReviewSummaryThis PR fixes AST formatting roundtrip for keyword-like function identifiers by ensuring ClickHouse Rules
Final Verdict
|
…ename test to avoid number conflict - Update `02868_select_support_from_keywords.reference`: column `from` is now backtick-quoted in SELECT lists (correct behavior — unquoted `from` would be ambiguous with the FROM clause keyword) - Update `02184_default_table_engine.reference`: `values(...)` function call is now backtick-quoted as `\`values\`(...)` in SHOW CREATE output - Update `03786_AST_formatting_inconsistencies_in_debug_check.reference`: `VALUES(...)` table function is now backtick-quoted in formatQuery output - Rename test 04093 → 04094 to avoid conflict with `04093_merge_function_custom_defaults_remote` merged from master Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…robablyQuotedStringImpl` The `strncasecmp` call is safe because the size is explicitly passed as the third argument, but clang-tidy 21 does not recognize that the second `data()` argument is length-bounded. Suppress with NOLINT. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov
added a commit
that referenced
this pull request
Apr 12, 2026
…_random` to fix timeout The test inserts 4 × 1,000,000 rows and runs FINAL queries. With randomized settings (especially `max_threads=1`) in a debug build, this exceeds the 600s timeout. Reduce to 200,000 rows per insert — still sufficient for skip index correctness testing with 3,125 granules per part (index_granularity=64). https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102338&sha=41026906138c371d1fe6cd79676d664f8abd5a4f&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 #102338 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov
added a commit
that referenced
this pull request
Apr 12, 2026
The test was timing out (>600s) under MSan with randomized settings. The `.sql.j2` template contained no Jinja2 syntax and the previous `Random settings limits` approach only constrained `index_granularity` and `index_granularity_bytes`, leaving other problematic settings (`merge_max_block_size`, `prewarm_mark_cache`, `prewarm_primary_key_cache`) unconstrained. Convert from `.sql.j2` to `.sql` (no template features used) and pin the same performance-critical MergeTree settings as the sibling `_2_wide_merge_tree.sql` test: `index_granularity`, `merge_max_block_size`, `prewarm_*_cache`, and `auto_statistics_types`. Also override `max_threads` and `min_bytes_to_use_direct_io` at session level. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102338&sha=41026906138c371d1fe6cd79676d664f8abd5a4f&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%201%2F2%29 #102338 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
alexey-milovidov
added a commit
to alexey-milovidov/ClickHouse
that referenced
this pull request
Apr 12, 2026
…_random` The test timed out (600s) in the debug flaky check when the randomizer set `--max_threads 1` — 4 million rows with FINAL queries is too slow for a debug build with a single thread. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102338&sha=41026906138c371d1fe6cd79676d664f8abd5a4f&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 ClickHouse#102338 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
george-larionov
approved these changes
Apr 13, 2026
| /// These keywords cause parsing ambiguity when used as function or identifier names | ||
| /// because the parser consumes them as clause-starting keywords. | ||
| && !isCaseInsensitiveEqual(s, "from") | ||
| && !isCaseInsensitiveEqual(s, "values")) |
Member
There was a problem hiding this comment.
This looks much nicer than the old implementation
Contributor
LLVM Coverage Report
Changed lines: 100.00% (11/11) · Uncovered code |
Contributor
|
I have a table with a Tuple(values String). I was lucky that the table was small and I could afford OPTIMIZE FINAL :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The BuzzHouse fuzzer found that when
FROMorVALUESare used as function names, the AST formatter outputs them without backtick-quoting. When parsing the formatted query back, the parser interprets these as SQL clause keywords instead of function names, causing a SYNTAX_ERROR.Add
FROMandVALUESto the list of keywords that must be backtick-quoted inwriteProbablyQuotedStringImpl, alongside the existingDISTINCT,ALL,TABLE, andSELECTentries.https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101054&sha=1a927fce3bc0eb606438ccc418daafbd3060ad2b&name_0=PR&name_1=BuzzHouse%20%28amd_debug%29
Changelog category (leave one):
Version info
26.5.1.78