sabir-akhadov-localstack commented on code in PR #2682:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2682#discussion_r4313128475
##########
src/parser/mod.rs:
##########
@@ -2642,7 +2642,26 @@ impl<'a> Parser<'a> {
let window_spec = self.parse_window_spec()?;
Some(WindowType::WindowSpec(window_spec))
} else {
- Some(WindowType::NamedWindow(self.parse_identifier()?))
+ let next_word_kw = match &self.peek_token_ref().token {
+ Token::Word(w) => Some(w.keyword),
+ _ => None,
+ };
+ let next_is_window_name = match next_word_kw {
+ Some(kw) => {
+ let dialect = self.dialect;
+ dialect.is_column_alias(&kw, self)
+ }
+ None => matches!(
+ &self.peek_token_ref().token,
+ Token::SingleQuotedString(_) |
Token::DoubleQuotedString(_)
+ ),
+ };
+ if self.dialect.supports_over_keyword_as_column_alias() &&
!next_is_window_name {
Review Comment:
`is_column_alias` runs here with the parser still positioned on the
candidate token, while `parse_optional_alias_inner` consumes it before calling
the hook, so overrides that peek ahead (Snowflake's looks at the token after
`EXCEPT`/`RETURNING`/`LIMIT`) see a different position at this site. The result
is discarded unless `supports_over_keyword_as_column_alias()` is true, so
nothing breaks today, but checking the flag before the lookahead would skip it
for every other dialect and keep the position mismatch from biting a dialect
that enables the flag later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]