Files
datastore/programs/format
Alexey MilovidovandClaude Opus 4.6 3be8cbbf33 Fix query obfuscator to produce parseable SQL in more cases
The query obfuscator (`clickhouse format --obfuscate`) was producing
unparseable SQL for many queries. This fixes several categories of issues:

1. Add missing keywords for SYSTEM commands (`FLUSH`, `LOGS`, `DNS`,
   `CACHE`, `RELOAD`, etc.), dictionary definitions (`FLAT`, `HASHED`,
   `CLICKHOUSE`, etc.), special SQL constructs (`EXTRACT`, `TRIM`,
   `DECIMAL`), multi-word data types (`NATIONAL`, `NCHAR`, `BINARY`,
   `LARGE`, `OBJECT`), and substitution syntax (`Identifier`).

2. Fix hex/binary number prefix corruption: `0x1234` was becoming
   `0p1234` because the `x` was treated as alphabetical and obfuscated.
   Now preserves `0x`/`0b` prefixes and handles hex float literals
   like `0xD.5p-6`.

3. Fix hex/binary string literal content corruption: `x'ABCD'` was
   producing invalid hex like `x'WXYZ'`. Now replaces hex digits with
   random hex digits and binary digits with random binary digits.

4. Make known identifier lookup case-insensitive: `DECIMAL` and
   `decimal` are now recognized as known types like `Decimal`.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-21 19:33:01 +00:00
..