-
Notifications
You must be signed in to change notification settings - Fork 621
Add support for Snowflake identifier function #1929
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
Conversation
src/parser/mod.rs
Outdated
} else if let Some(func_part) = | ||
self.maybe_parse(|parser| parser.parse_object_name_function_part())? |
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.
wondering can we instead extende the else
clause to do something like this?
else {
let ident = self.parse_identifier()?;
let part = if self.dialect.is_identifier_generating_function_name(&ident) {
self.expect_token(&Token::LParen)?;
let args = ...
self.expect_token(&Token::RParen)?;
ObjectNamePartFunction { name:ident, args }
} else {
ObjectNamePart::Identifier(ident));
}
}
thinking that way we skip this extra branch, and the extra error scenario in the function part parsing
@@ -4232,3 +4232,122 @@ fn test_snowflake_create_view_with_composite_policy_name() { | |||
r#"CREATE VIEW X (COL WITH MASKING POLICY foo.bar.baz) AS SELECT * FROM Y"#; | |||
snowflake().verified_stmt(create_view_with_tag); | |||
} | |||
|
|||
#[test] |
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 add a test scenario for how this interacts with the double dot feature?
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.
In what way? I believe you cannot chain IDENTIFIER. For example, this is illegal: SELECT * FROM IDENTIFIER('db1')..IDENTIFIER('tbl1').
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.
Yeah was thinking a test as in your example to demonstrate if/how the parser handles it. If its unsupported then it'll be a negative test
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.
LGTM! Thanks @yoavcloud!
cc @alamb
Expand the support for the
IDENTIFIER
function in Snowflake, which is used to generate identifiers dynamically. See here: https://docs.snowflake.com/en/sql-reference/identifier-literalThe ObjectNamePart enum was extended with a new part type to support the use of the identifier function as an object name. Some work went into organizing
Parser:parse_object_name
a bit.A few examples: