Repository navigation
Add /dialect, /lang, /language client commands - #114568
Conversation
The commands are equivalent to `SET dialect = '...'`, but are handled
on the client side before parsing, so they also work when the current
dialect cannot parse a `SET` query (for example, to leave `kusto` or
`promql`). Without an argument, `/dialect` prints the current dialect.
When the dialect is not `clickhouse`, it is displayed in the prompt
after the server display name in parentheses, with a separating space
if the display name is non-empty:
clickhouse-cloud (polyglot) :)
Co-Authored-By: Claude Fable 5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Workflow [PR], commit [254f802] Summary: ✅
AI ReviewSummaryThis revision adds interactive Missing context / blind spots
Final Verdict
LLVM Coverage ReportMeasured on commit 254f802.
Changed lines: Changed C/C++ lines covered: 205/213 (96.24%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes14 object files changed (-71.35 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units95 translation units recompiled, 451 s compile time in total, 95 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
…name}`
`getPrompt` rendered the active dialect only through the `{display_name}`
placeholder, so a custom prompt such as `--prompt '{user}@{host}'` never
showed it. Append the indicator at the end of the prompt (before the
trailing `:) `, if any) when the prompt does not carry `{display_name}`,
and cover it with a test.
Also renumber the test to `04892_client_dialect_command` to avoid a
collision after merging `master`.
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114568&sha=4e206dd0fb7765d98b6f6e6717c4dd4ee16bad72&name_0=PR&name_1=Fast%20test and provide a fix in a separate PR. |
|
It is caused by this PR. The test file is unchanged from master, but the failing line goes through a path this diff adds. The failing step is line 20, The only arming condition is a trailing newline, which the test's A/B with debug builds of
So it is not specific to The defect is inside this PR's own diff, so I am not opening a separate PR for it. The smallest fix I validated is to arm the new block only when the input actually contains a dialect-command line: if (supportsLocalMetaCommands() && !is_interactive && text.contains('\n')
&& has_dialect_command_line(text))with the existing prints Not addressed: a script mixing a text-level meta with a Tell me if you would rather have this as a PR against master for you to cherry-pick. |
|
🕵 Addressed in 85ca0f7: the noninteractive |
|
🕵 Merged
Verified locally: |
`ParserTrinoQuery` handles every `SET` form itself, including the Trino `SET SESSION name = value` and `SET ROLE`. The client-side escape checks only for a valid `SET` prefix (`SET SESSION` reads as a boolean flag), so it sent `SET SESSION max_block_size = 12345` to `ParserQuery` and failed with `SYNTAX_ERROR`; the same statement was also pinned to `dialect = 'clickhouse'` for the server. Exclude `trino` from both. Fixes the `Fast test` red in `05153_trino_dialect_wrappers_and_set`: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=114568&sha=a4b1c83e860f3160cbef5e28bfb55b57c51aaae8&name_0=PR&name_1=Fast%20test PR: #114568 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Merged
Local run: |
# Conflicts: # src/Client/LocalConnection.cpp
…he other parse-time gates The `logsql` dialect arrived from master with its own parse-time gate. A query-local `SETTINGS allow_experimental_logsql_dialect = ...` must not change how this very query text is parsed on the server, same as `enable_trino_dialect` and `enable_json_ast_dialect`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…to a single-command input The diagnostic runs only when the whole input of `clickhouse-local` is the command, like the `/`-commands themselves; inside a multi-statement script the text goes to `executeMultiQuery`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SET name` The generic SQL `SET` escape probed the input with a default `ParserSetQuery`, which accepts the shorthand `SET name` form. A `LogsQL` word filter such as `set error | count()` or `set error` was then parsed as a SQL `SET`, failing with a syntax error or with `Unknown setting 'error'`. The `LogsQL` parser already has its own escape that keeps such word filters, so `logsql` is excluded from the generic escape like `trino`, and the shorthand form is disabled in the probe (it would also steal the KQL `set notruncation`). https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=114568&sha=2b3f121b3be288818a00bf8d9efa86b50a0c2076&name_0=PR&name_1=Fast%20test #114568 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l` applying `SET profile` The last step of the test checked that the Kusto profile was in effect for the following queries by expecting `SELECT 1` to be rejected. Since ClickHouse#114568, `clickhouse-local` does not apply the settings of `SET profile` to later queries (ClickHouse#123916, fix pending in ClickHouse#125171), so `SELECT 1` succeeds and the test times out in Fast test. That step only guarded against the profile carrying nothing parser-shaping. Check this on the profile definition in `system.settings_profile_elements` instead, before `SET profile`, so the test holds both with and without the `clickhouse-local` fix. The continuation assertion itself is unchanged. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=101785&sha=9a99a51ef1b3008f00aff04d4b0a27d499db078d&name_0=PR&name_1=Fast%20test PR: ClickHouse#101785 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…khouse-local` Since ClickHouse#114568, `LocalConnection::sendQuery` replaced the whole `Settings` of the query context with the client's copy. The client does not track `profile` (its `SET` bookkeeping skips it), so the settings a `SET profile` installed in the session were dropped for every following query: `currentProfiles` reported the profile, while `getSetting` showed the old values and a `readonly` profile did not block writes. Apply only `changes` of the client settings, like `TCPHandler`. Closes: ClickHouse#123916 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds client-side
/dialect,/langand/languagecommands - an equivalent ofSET dialect = '...'that is handled before parsing, so it also works when the current dialect cannot express aSETquery (for example, to leavekustoorpromql). The active non-default dialect is shown in the prompt, and a plainSET dialect = '...'keeps the prompt in sync.Implementation notes:
getPrompton every line from a template that keeps the{display_name}placeholder: the current dialect is appended to the display name in parentheses (with a separating space if the display name is non-empty), and the:)smiley is appended at the end, preserving the previous behavior for the default dialect. A custom prompt without{display_name}gets the dialect appended at its end.clickhouse-client,clickhouse-local, and the embedded client (SSH/web terminal). A noninteractive script is parsed as SQL from end to end, and the dialect for it is selected with the--dialectoption or with aSET dialect = ...statement, as before.SETquery is now an escape hatch out of every non-ClickHouse dialect, not only out ofclickhouse_json. It is recognized by actually parsing it withParserSetQueryrather than by looking at the first token, so a valid query of the current dialect that merely starts with the wordset(a PromQL metric namedset) is not hijacked.clickhouse-localscript the command is rejected with an explicit message ("available in interactive mode only") and is not suggested for a misspelled/-command; the other/-commands keep working there.04892_client_dialect_command.expect.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added the interactive client commands
/dialect,/lang, and/languagetoclickhouse-clientandclickhouse-local, so you can switch the active SQL dialect before parsing - it also works when the current dialect cannot express aSETquery, for example to leavekustoorpromql. The current non-default dialect is now shown in the prompt, and a plainSET dialect = ...keeps the prompt in sync.Workflow [PR]
Sync PR [sync-upstream/pr/114568]
Version info
26.10.1.1535-master(included in26.10and later)