@@ -6879,17 +6879,16 @@ impl<'a> Parser<'a> {
68796879
68806880 // parse optional column list (schema)
68816881 let (columns, constraints) = self.parse_columns()?;
6882- let mut comment = if dialect_of!(self is HiveDialect)
6883- && self.parse_keyword(Keyword::COMMENT)
6884- {
6885- let next_token = self.next_token();
6886- match next_token.token {
6887- Token::SingleQuotedString(str) => Some(CommentDef::AfterColumnDefsWithoutEq(str)),
6888- _ => self.expected("comment", next_token)?,
6889- }
6890- } else {
6891- None
6892- };
6882+ let comment_after_column_def =
6883+ if dialect_of!(self is HiveDialect) && self.parse_keyword(Keyword::COMMENT) {
6884+ let next_token = self.next_token();
6885+ match next_token.token {
6886+ Token::SingleQuotedString(str) => Some(CommentDef::WithoutEq(str)),
6887+ _ => self.expected("comment", next_token)?,
6888+ }
6889+ } else {
6890+ None
6891+ };
68936892
68946893 // SQLite supports `WITHOUT ROWID` at the end of `CREATE TABLE`
68956894 let without_rowid = self.parse_keywords(&[Keyword::WITHOUT, Keyword::ROWID]);
@@ -6937,13 +6936,6 @@ impl<'a> Parser<'a> {
69376936
69386937 let strict = self.parse_keyword(Keyword::STRICT);
69396938
6940- // Excludes Hive dialect here since it has been handled after table column definitions.
6941- if !dialect_of!(self is HiveDialect) && self.parse_keyword(Keyword::COMMENT) {
6942- // rewind the COMMENT keyword
6943- self.prev_token();
6944- comment = self.parse_optional_inline_comment()?
6945- };
6946-
69476939 // Parse optional `AS ( query )`
69486940 let query = if self.parse_keyword(Keyword::AS) {
69496941 Some(self.parse_query()?)
@@ -6972,7 +6964,7 @@ impl<'a> Parser<'a> {
69726964 .without_rowid(without_rowid)
69736965 .like(like)
69746966 .clone_clause(clone)
6975- .comment(comment )
6967+ .comment_after_column_def(comment_after_column_def )
69766968 .order_by(order_by)
69776969 .on_commit(on_commit)
69786970 .on_cluster(on_cluster)
@@ -7033,7 +7025,11 @@ impl<'a> Parser<'a> {
70337025 };
70347026 }
70357027
7036- let plain_options = self.parse_plain_options()?;
7028+ let plain_options = if dialect_of!(self is HiveDialect) {
7029+ vec![]
7030+ } else {
7031+ self.parse_plain_options()?
7032+ };
70377033
70387034 Ok(CreateTableConfiguration {
70397035 partition_by,
@@ -7056,11 +7052,19 @@ impl<'a> Parser<'a> {
70567052 Keyword::CHARSET,
70577053 Keyword::COLLATE,
70587054 Keyword::INSERT_METHOD,
7055+ Keyword::COMMENT,
70597056 ]) {
7060- let _ = self.consume_token(&Token::Eq);
7057+ let has_eq = self.consume_token(&Token::Eq);
70617058 let value = self.next_token();
70627059
70637060 match (keyword, value.token) {
7061+ (Keyword::COMMENT, Token::SingleQuotedString(s)) => {
7062+ let comment = match has_eq {
7063+ true => CommentDef::WithEq(s),
7064+ false => CommentDef::WithoutEq(s),
7065+ };
7066+ return Ok(Some(SqlOption::Comment(comment)));
7067+ }
70647068 (Keyword::AUTO_INCREMENT, Token::Number(n, l)) => {
70657069 // validation
70667070 let _ = Some(Self::parse::<u32>(n.clone(), value.span.start)?);
0 commit comments