Repository navigation
DuckDB: support the ==, ** and ~~ operators and chained signs - #2795
Merged
Merged
Conversation
guizmaii
marked this pull request as ready for review
October 13, 2026 08:33
27 tasks
Contributor
|
Please resolve conflicts. |
guizmaii
force-pushed
the
duckdb-operators
branch
from
October 13, 2026 10:42
0b2a6d0 to
d79008a
Compare
- `a == b` is `EqualsTo` with the `==` spelling. - `a ** b` is the new `Exponentiation`, above the multiplicative operators and left-associative, as in DuckDB. - `~~`, `~~*`, `~~~`, `!~~` and `!~~*` are `LIKE`, `ILIKE`, `GLOB` and their negations, kept as written. `a ~~ 'x'` used to parse as the regular expression match `a ~ (~'x')`. - `- -1`, `+-+1` and `~ ~a` nest signs. A sign is separated from an operand starting with the same sign so that `- -1` does not deparse as the comment `--1`, nor `~ ~a` as `~~a`.
- The `~~` spelling is now derived from the keyword and `NOT`, so `setNot` or `setLikeKeyWord` no longer leave a stale operator, and `PRIOR` and `BINARY` are printed with it. `!~~~` and `null` are rejected. - A sign is also separated from an operand when either is `~`: DuckDB and PostgreSQL read `-~1` as one unknown operator. - `**` is the `OP_POWER` token; the `MulChain` alternative was never reached. - `visit(Exponentiation)` is a default method, so existing `ExpressionVisitor` implementations keep compiling.
guizmaii
force-pushed
the
duckdb-operators
branch
from
October 13, 2026 12:41
d79008a to
8523ca9
Compare
Contributor
|
Thank you! |
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.
For DuckDB (operators, numeric, pattern matching).
a == bEqualsTo, spelled==2 * 3 ** 2Multiplication(2, Exponentiation(3, 2))a ~~ 'x'RegExpMatchOperator(a, ~'x')(wrong tree)LikeExpressionLIKE, spelled~~a !~~* 'x'LikeExpressionNOT ILIKE, spelled!~~*a ~~~ 'x*'LikeExpressionGLOB- -1,+-+1,~ ~aSignedExpressionExponentiationis a newBinaryExpression;ExpressionVisitor.visit(Exponentiation)is a default method, so existing visitors keep compiling. Its precedence matches DuckDB: above*, left-associative, below the unary sign (-2 ** 2= 4).^staysBitwiseXorat the level of*, so2^3**2still differs from DuckDB's power^.LikeExpression.setLikeOperatorsets the keyword andNOTfrom the operator; the operator spelling is then derived from them, so latersetNot/setLikeKeyWordcalls print consistently (falling back to the keyword form, e.g. forNOT GLOB).~, or both are-:- -1must not deparse as the comment--1, nor- ~1/~ ~aas the single operators-~/~~.a ~~banda !~~bused to parse as a regular expression match against~b; they are nowLIKE/NOT LIKE, as in PostgreSQL and DuckDB. Unspaced~~afailed before and still does.//(lexed as a Snowflake line comment),^@and postfixa NOT NULL.checkGrammarAmbiguity: no conflicts../gradlew check: 10,121 tests, 0 failures.test/sql, 70,729 statements): 199 more parse, none less.