@@ -6878,17 +6878,16 @@ impl<'a> Parser<'a> {
68786878
68796879 // parse optional column list (schema)
68806880 let (columns, constraints) = self.parse_columns()?;
6881- let mut comment = if dialect_of!(self is HiveDialect)
6882- && self.parse_keyword(Keyword::COMMENT)
6883- {
6884- let next_token = self.next_token();
6885- match next_token.token {
6886- Token::SingleQuotedString(str) => Some(CommentDef::AfterColumnDefsWithoutEq(str)),
6887- _ => self.expected("comment", next_token)?,
6888- }
6889- } else {
6890- None
6891- };
6881+ let comment_after_column_def =
6882+ if dialect_of!(self is HiveDialect) && self.parse_keyword(Keyword::COMMENT) {
6883+ let next_token = self.next_token();
6884+ match next_token.token {
6885+ Token::SingleQuotedString(str) => Some(CommentDef::WithoutEq(str)),
6886+ _ => self.expected("comment", next_token)?,
6887+ }
6888+ } else {
6889+ None
6890+ };
68926891
68936892 // SQLite supports `WITHOUT ROWID` at the end of `CREATE TABLE`
68946893 let without_rowid = self.parse_keywords(&[Keyword::WITHOUT, Keyword::ROWID]);
@@ -6936,13 +6935,6 @@ impl<'a> Parser<'a> {
69366935
69376936 let strict = self.parse_keyword(Keyword::STRICT);
69386937
6939- // Excludes Hive dialect here since it has been handled after table column definitions.
6940- if !dialect_of!(self is HiveDialect) && self.parse_keyword(Keyword::COMMENT) {
6941- // rewind the COMMENT keyword
6942- self.prev_token();
6943- comment = self.parse_optional_inline_comment()?
6944- };
6945-
69466938 // Parse optional `AS ( query )`
69476939 let query = if self.parse_keyword(Keyword::AS) {
69486940 Some(self.parse_query()?)
@@ -6971,7 +6963,7 @@ impl<'a> Parser<'a> {
69716963 .without_rowid(without_rowid)
69726964 .like(like)
69736965 .clone_clause(clone)
6974- .comment(comment )
6966+ .comment_after_column_def(comment_after_column_def )
69756967 .order_by(order_by)
69766968 .on_commit(on_commit)
69776969 .on_cluster(on_cluster)
@@ -7032,7 +7024,11 @@ impl<'a> Parser<'a> {
70327024 };
70337025 }
70347026
7035- let plain_options = self.parse_plain_options()?;
7027+ let plain_options = if dialect_of!(self is HiveDialect) {
7028+ vec![]
7029+ } else {
7030+ self.parse_plain_options()?
7031+ };
70367032
70377033 Ok(CreateTableConfiguration {
70387034 partition_by,
@@ -7055,11 +7051,19 @@ impl<'a> Parser<'a> {
70557051 Keyword::CHARSET,
70567052 Keyword::COLLATE,
70577053 Keyword::INSERT_METHOD,
7054+ Keyword::COMMENT,
70587055 ]) {
7059- let _ = self.consume_token(&Token::Eq);
7056+ let has_eq = self.consume_token(&Token::Eq);
70607057 let value = self.next_token();
70617058
70627059 match (keyword, value.token) {
7060+ (Keyword::COMMENT, Token::SingleQuotedString(s)) => {
7061+ let comment = match has_eq {
7062+ true => CommentDef::WithEq(s),
7063+ false => CommentDef::WithoutEq(s),
7064+ };
7065+ return Ok(Some(SqlOption::Comment(comment)));
7066+ }
70637067 (Keyword::AUTO_INCREMENT, Token::Number(n, l)) => {
70647068 // validation
70657069 let _ = Some(Self::parse::<u32>(n.clone(), value.span.start)?);
0 commit comments