Setting Query without Value will Set Value To 1#85800
Setting Query without Value will Set Value To 1#85800serxa merged 10 commits intoClickHouse:masterfrom
Conversation
Example: SELECT 1 SETTINGS use_query_cache; is equivalent to SELECT 1 SETTINGS use_query_cache=1;
|
Workflow [PR], commit [e9c7e4b] Summary: ❌
|
…nternal When ParserSetQuery is initalized with parse_only_internal = true, it checks for an '=' to know if there is setting to be updated. If no '=', then parser returns false. Since the shorthand notation removes the equal sign, we need a way to handle for both parse_only_internal = true and false. parse_only_internal is passed to parseNameValuePairWithParameterOrDefault to handle the different paths.
- SET and SETTINGS are keywords in query to indicate there is setting set to a value. - EXPLAIN query allows for settings to be set after EXPLAIN type keyword. - No SET or SETTING keyword to indicate setting to be set to a value. - Equal sign is used to determine if there is setting to be set to a value. - Without equal sign, there is no way (to my knowledge) of determining if the current token is a setting without checking if setting exists or if the current token is a keyword. - To avoid ParserSetQuery to take a perf hit by checking setting or for keyword did not add shorthand syntax feature to EXPLAIN queries. - As a result, added shorthand_syntax member of ParserSetQuery which is default to true - EXPLAIN set to false for reasons above - added more test cases
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a shorthand syntax for setting boolean values to true in ClickHouse queries. Instead of explicitly writing setting_name = 1, users can now simply write setting_name which automatically sets the value to 1.
Key changes include:
- Modified parser logic to support shorthand syntax for settings without explicit values
- Added comprehensive test coverage for the new functionality
- Updated documentation to explain the new shorthand syntax
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/Parsers/ParserSetQuery.h |
Added shorthand_syntax parameter to parser class |
src/Parsers/ParserSetQuery.cpp |
Implemented core logic to handle settings without explicit values |
src/Parsers/ParserExplainQuery.cpp |
Disabled shorthand syntax for EXPLAIN queries |
tests/queries/0_stateless/03595_set_query_no_eq_set_to_one.sql |
Comprehensive test cases for new functionality |
tests/queries/0_stateless/03595_set_query_no_eq_set_to_one.reference |
Expected output for test cases |
docs/en/sql-reference/statements/set.md |
Documentation for SET statement shorthand |
docs/en/sql-reference/statements/select/index.md |
Documentation for SELECT statement settings |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Failed test is unrelated
|
a43c9ac
|
@thraeka @serxa It seems like integer-type settings are also implicitly considered 1 ([example fiddle](https://fiddle.clickhouse.com/037348b1-3eb1-4ecc-9936-a6d62fb1dd23, docs). In the general case, I think this is confusing. May I ask to fix this please? |
|
@rschu1ze I'll have a pull request with your request hopefully sometime this week. |
Closes #85676
Example:
is equivalent to
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Treat a bare setting name in query setting as equal to
1(e.g.SELECT ... SETTINGS use_query_cacheis equivalent touse_query_cache = 1).