Repository navigation
Spark, Databricks: parse the << and >> shift operators - #15
Merged
moshap-firebolt merged 1 commit intoOct 4, 2026
Merged
Conversation
Both dialects have them. Spark's grammar binds a shift tighter than & and looser than +, so the dialects place it just above Ampersand rather than at the shared Caret level, which sits below &.
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.
Spark and Databricks both have the
<<and>>bitwise shift operators. The parser already supports them behindsupports_bitwise_shift_operators; this turns that on forSparkSqlDialectandDatabricksDialect.Spark's grammar binds a shift tighter than
&and looser than+. The shared default puts shifts at theCaretlevel, which sits below&, so1 & 3 << 1would read as(1 & 3) << 1. Both dialects overrideget_next_precedenceto place shifts just aboveAmpersand.Tests in
tests/sqlparser_spark.rscover both operators, the operator tag, and the tree shape against&and+. The fork's full suite, fmt and clippy are clean.Note
Low Risk
Dialect-only parser changes with targeted tests; no auth, data, or runtime execution paths affected.
Overview
Spark and Databricks now parse bitwise shift operators
<<and>>by enablingsupports_bitwise_shift_operatorson both dialects.Both dialects override
get_next_precedenceso shifts bind tighter than&and looser than+(e.g.1 & 3 << 1→1 & (3 << 1)), matching Spark’s grammar instead of the default precedence that would group shifts below&.Spark tests in
test_bitwise_shift_operatorscover parsing, operator kinds, and precedence against&and+.Reviewed by Cursor Bugbot for commit b4c500b. Bugbot is set up for automated code reviews on this repo. Configure here.