Skip to content

Setting Query without Value will Set Value To 1#85800

Merged
serxa merged 10 commits intoClickHouse:masterfrom
thraeka:set_query_no_eq_set_to_one
Aug 27, 2025
Merged

Setting Query without Value will Set Value To 1#85800
serxa merged 10 commits intoClickHouse:masterfrom
thraeka:set_query_no_eq_set_to_one

Conversation

@thraeka
Copy link
Copy Markdown
Contributor

@thraeka thraeka commented Aug 18, 2025

Closes #85676

Example:

SELECT 1 SETTINGS use_query_cache;

is equivalent to

SELECT 1 SETTINGS use_query_cache=1;

Changelog category (leave one):

  • New Feature

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_cache is equivalent to use_query_cache = 1).

Example:
SELECT 1 SETTINGS use_query_cache;
is equivalent to
SELECT 1 SETTINGS use_query_cache=1;
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Aug 18, 2025

CLA assistant check
All committers have signed the CLA.

@thraeka thraeka changed the title Setting Query without Value will Set Value To 1#85676 Setting Query without Value will Set Value To 1 Aug 18, 2025
@serxa serxa self-assigned this Aug 18, 2025
@serxa serxa added the can be tested Allows running workflows for external contributors label Aug 18, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Aug 18, 2025

Workflow [PR], commit [e9c7e4b]

Summary:

job_name test_name status info comment
AST fuzzer (arm_asan) failure
ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50d000279097 at pc 0xab6d2eb23c00 bp 0xffb534a22f50 sp 0xffb534a22f48 FAIL

@clickhouse-gh clickhouse-gh bot added the pr-feature Pull request with new product feature label Aug 18, 2025
…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
@serxa serxa requested a review from Copilot August 26, 2025 15:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@serxa serxa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, requires a minor tweak

@serxa
Copy link
Copy Markdown
Member

serxa commented Aug 27, 2025

Failed test is unrelated

AST fuzzer (arm_asan) AddressSanitizer: heap-buffer-overflow

#86260

@serxa serxa enabled auto-merge August 27, 2025 10:05
@serxa serxa added this pull request to the merge queue Aug 27, 2025
Merged via the queue into ClickHouse:master with commit a43c9ac Aug 27, 2025
120 of 122 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 27, 2025
@rschu1ze
Copy link
Copy Markdown
Member

@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?

@thraeka
Copy link
Copy Markdown
Contributor Author

thraeka commented Sep 10, 2025

@rschu1ze I'll have a pull request with your request hopefully sometime this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Statement-level settings with default values

6 participants