-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(clickhouse): parse ternary operator #1603
Conversation
@@ -2985,8 +2999,18 @@ def _parse_column(self) -> t.Optional[exp.Expression]: | |||
field = self._parse_types() | |||
if not field: | |||
self.raise_error("Expected type") | |||
elif op: | |||
elif op and self._curr: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without self._curr
here we might raise an index error in the self._advance
call below (happened earlier).
sqlglot/parser.py
Outdated
self._prev.token_type != TokenType.STRING | ||
or self._match_set(self.TERNARY_OPERATOR_TOKENS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the prev token is a STRING
we can't immediately disambiguate between a JSONBContains expression (x ? 'foo'
in postgres) and a ternary operator.
maybe this should be clickhouse only so you don't have to worry about conflicts. also, maybe you should treat it like the exponent use case for postgres. it can have another precedence |
* Feat(clickhouse): parse ternary operator * Formatting * Refactor * Fixup * Fixup
Fixes #1602