Fix Oracle dialect crash on parenthesized LIKE expression#7121
Merged
georgesittas merged 1 commit intotobymao:mainfrom Feb 22, 2026
Merged
Fix Oracle dialect crash on parenthesized LIKE expression#7121georgesittas merged 1 commit intotobymao:mainfrom
georgesittas merged 1 commit intotobymao:mainfrom
Conversation
Oracle's _parse_column_ops speculatively calls _parse_interval_span, which internally calls _parse_function. When the current token is LIKE followed by parenthesized arguments (e.g. LIKE (:var)), _parse_function consumes the LIKE token and tries to validate it as a function call, raising a ParseError because Like requires a 'this' argument. Use _try_parse to wrap the speculative _parse_interval_span call so that parse errors are caught and the parser state is properly restored. Fixes tobymao#7118. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Fixes #7118.
SELECT * FROM t WHERE c LIKE (:var)crashes withParseError: Required keyword: 'this' missing for <class 'sqlglot.expressions.Like'>in the Oracle dialect.Root cause: Oracle's
_parse_column_opsspeculatively calls_parse_interval_span, which internally calls_parse_function(). When the current token isLIKEfollowed by parenthesized arguments,_parse_functionconsumesLIKEand tries to validateLIKE(:var)as a function call — butLikerequires athisargument that isn't present, so it raises aParseError. The existing retreat logic on line 300 never executes because the error is thrown first.Fix: Wrap the speculative
_parse_interval_spancall in_try_parse, which catchesParseErrorand properly restores the parser state. This follows the same pattern used elsewhere in the parser for speculative parsing.All 23 Oracle dialect tests pass (211 subtests). General parser tests also pass.