support PIVOT table syntax#836
Merged
Merged
Conversation
Pull Request Test Coverage Report for Build 4466498674
💛 - Coveralls |
Contributor
Author
|
Failing lint should be resolved within #835 |
ankrgyl
reviewed
Mar 18, 2023
| alias: Option<TableAlias>, | ||
| }, | ||
| /// Represents PIVOT operation on a table. | ||
| /// For example `FROM monthly_sales PIVOT(sum(amount) FOR MONTH IN ('JAN', 'FEB'))` |
Contributor
There was a problem hiding this comment.
Could you add a link to the Snowflake docs (https://docs.snowflake.com/en/sql-reference/constructs/pivot) in here?
| #[test] | ||
| fn parse_pivot_table() { | ||
| let sql = concat!( | ||
| "SELECT * FROM monthly_sales AS a ", |
Contributor
There was a problem hiding this comment.
- can you add a test case without the
AScomponent? - can you add a roundtrip test (so we can verify the
Display()implementation works too)
Contributor
Author
There was a problem hiding this comment.
- There is below a variable
sql_without_table_aliasthat tests this. - Will add the roundtrip as it is missing.
| self.expect_token(&Token::LParen)?; | ||
| let function_name = match self.next_token().token { | ||
| Token::Word(w) => Ok(w.value), | ||
| _ => self.expected("a function name", self.peek_token()), |
Contributor
There was a problem hiding this comment.
maybe "an aggregate function" in the error message?
| }?; | ||
| let function = self | ||
| .parse_function(ObjectName(vec![Ident::new(function_name)])) | ||
| .unwrap(); |
Contributor
There was a problem hiding this comment.
shouldn't we propagate the error here instead of unwrapping?
| .parse_function(ObjectName(vec![Ident::new(function_name)])) | ||
| .unwrap(); | ||
| self.expect_keyword(Keyword::FOR)?; | ||
| let mut value_column = vec![self.parse_identifier()?]; |
Contributor
There was a problem hiding this comment.
why not use self.parse_object_name()?
Signed-off-by: Pawel Leszczynski <leszczynski.pawel@gmail.com>
0fcafd9 to
883c7c0
Compare
alamb
approved these changes
Mar 26, 2023
alamb
left a comment
Contributor
There was a problem hiding this comment.
Thank you @pawel-big-lebowski -- looks good to me. Thanks for the assist @ankrgyl
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.
PIVOT TABLEsyntax is available in Snowflake.This PR introduces
PIVOTsupport within sqlparser-rs.