7phs commented on code in PR #1755: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1755#discussion_r1994036120
########## src/parser/mod.rs: ########## @@ -6922,18 +6924,23 @@ impl<'a> Parser<'a> { }) } - pub fn parse_optional_inline_comment(&mut self) -> Result<Option<CommentDef>, ParserError> { + pub fn parse_optional_inline_comment( + &mut self, + support_dollar_quoted_comment: bool, + ) -> Result<Option<CommentDef>, ParserError> { let comment = if self.parse_keyword(Keyword::COMMENT) { let has_eq = self.consume_token(&Token::Eq); let next_token = self.next_token(); - match next_token.token { - Token::SingleQuotedString(str) => Some(if has_eq { - CommentDef::WithEq(str) - } else { - CommentDef::WithoutEq(str) - }), + let comment = match next_token.token { + Token::SingleQuotedString(str) => str, + Token::DollarQuotedString(str) if support_dollar_quoted_comment => str.value, Review Comment: A parameter `support_dollar_quoted_comment` is removed. ########## tests/sqlparser_snowflake.rs: ########## @@ -976,6 +976,27 @@ fn parse_sf_create_or_replace_with_comment_for_snowflake() { } } +#[test] +fn parse_sf_create_table_or_view_with_dollar_quoted_comment() { + assert!(snowflake() + .parse_sql_statements( + r#"CREATE OR REPLACE TEMPORARY VIEW foo.bar.baz ( + "COL_1" COMMENT $$comment 1$$ + ) COMMENT = $$view comment$$ AS ( + SELECT 1 + )"# + ) + .is_ok()); + + assert!(snowflake() + .parse_sql_statements( + r#"CREATE TABLE my_table ( + a STRING COMMENT $$comment 1$$ + ) COMMENT = $$table comment$$"# + ) Review Comment: 1. There is no code for storing a comment quotation. Could you clarify whether it makes sense to update all the code that handles comment? 2. Snowflake converts a dollar-quoted comment into a single-quoted comment in the DDL representation of table/view creation. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org