-
Notifications
You must be signed in to change notification settings - Fork 597
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
Support for projection item prefix operator (CONNECT_BY_ROOT) #1780
base: main
Are you sure you want to change the base?
Support for projection item prefix operator (CONNECT_BY_ROOT) #1780
Conversation
@@ -1237,6 +1237,23 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
|
|||
//Select item operators |
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.
//Select item operators | |
/// Select item operators |
for the doc comment can we describe what the function does?
let prefix = self | ||
.maybe_parse(|parser| parser.parse_select_item_prefix_by_reserved_word())? | ||
.flatten(); | ||
|
||
match self.parse_wildcard_expr()? { |
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.
Thinking introducing the prefix field into the select item is a bit more invasive and would be nice to avoid if it makes sense. I noticed this use case is similar in representation to IntroducedString, maybe we can repurpose that one to be generic.
I'm thinking something like this?
changing that enum variant into
Expr::Prefixed { prefix: Ident, expr: Expr }
Then impl wise here we could wrap the self.parse_wildcard_expr()
call with the logic to optionally parse the prefix
fn parse_select_item_expr() {
let prefix = self.parse_one_of_keywords(self.dialect.get_reserved_keywords_for_select_item());
let expr = self.parse_wildcard_expr()?
if let Some(prefix) = prefix {
Expr::Prefixed {
prefix: Ident::new(prefix),
expr,
}
} else {
expr
}
}
|
||
/// See: <https://docs.snowflake.com/en/sql-reference/constructs/connect-by> | ||
fn get_reserved_keywords_for_select_item_operator(&self) -> &[Keyword] { | ||
const RESERVED_KEYWORDS_FOR_SELECT_ITEM_OPERATOR: [Keyword; 1] = [Keyword::CONNECT_BY_ROOT]; |
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.
could we move this to the top of the file maybe? thinking it would be more visible there and if the list happens to get long it doesnt add to the function's length
Co-authored-by: Ifeanyi Ubah <[email protected]>
Co-authored-by: Ifeanyi Ubah <[email protected]>
Co-authored-by: Ifeanyi Ubah <[email protected]>
Support for the snowflake CONNECT_BY_ROOT operator
https://docs.snowflake.com/en/sql-reference/constructs/connect-by