Support BETWEEN SYMMETRIC and explicit ASYMMETRIC#106057
Open
BITree2004 wants to merge 1 commit into
Open
Conversation
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.
Closes #105955.
Summary
This PR adds parser support for PostgreSQL-style
BETWEENqualifiers:BETWEEN ASYMMETRICas an explicit no-op qualifier for existingBETWEENbehavior.NOT BETWEEN ASYMMETRICas an explicit no-op qualifier for existingNOT BETWEENbehavior.BETWEEN SYMMETRIC, which checks an inclusive range regardless of endpoint order.NOT BETWEEN SYMMETRIC, which checks values outside that unordered inclusive range.Implementation
The symmetric form is lowered through ordinary comparison operators:
and for
NOT BETWEEN SYMMETRIC:This avoids rewriting through
least()/greatest(), because in ClickHouse theirNULLbehavior depends onleast_greatest_legacy_null_behavior.The change also updates:
Compatibility note
SYMMETRICandASYMMETRICare parsed as contextual range qualifiers immediately afterBETWEENorNOT BETWEEN.If a column with one of these names is used as the lower bound in that position, it must be quoted:
Testing
Built and tested locally with Clang 21.1.6:
PATH=/home/bitree/repo/toolchains/LLVM-21.1.6-Linux-X64/bin:$PATH \ ninja -C build-pr-clang21 -j6 clickhouseThe build completed successfully and linked
build-pr-clang21/programs/clickhouse.For the local build, Rust, HDFS, ISA-L, and embedded LLVM/JIT/DWARF/BLAKE3 were disabled because those optional components required missing local tools or were not needed for this parser/stateless validation.
Manually checked parser/runtime behavior:
Result:
Ran the relevant stateless tests against a local server started from the same binary:
Both tests passed.