@@ -6878,17 +6878,16 @@ impl<'a> Parser<'a> {
6878
6878
6879
6879
// parse optional column list (schema)
6880
6880
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
+ };
6892
6891
6893
6892
// SQLite supports `WITHOUT ROWID` at the end of `CREATE TABLE`
6894
6893
let without_rowid = self.parse_keywords(&[Keyword::WITHOUT, Keyword::ROWID]);
@@ -6936,13 +6935,6 @@ impl<'a> Parser<'a> {
6936
6935
6937
6936
let strict = self.parse_keyword(Keyword::STRICT);
6938
6937
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
-
6946
6938
// Parse optional `AS ( query )`
6947
6939
let query = if self.parse_keyword(Keyword::AS) {
6948
6940
Some(self.parse_query()?)
@@ -6971,7 +6963,7 @@ impl<'a> Parser<'a> {
6971
6963
.without_rowid(without_rowid)
6972
6964
.like(like)
6973
6965
.clone_clause(clone)
6974
- .comment(comment )
6966
+ .comment_after_column_def(comment_after_column_def )
6975
6967
.order_by(order_by)
6976
6968
.on_commit(on_commit)
6977
6969
.on_cluster(on_cluster)
@@ -7032,7 +7024,11 @@ impl<'a> Parser<'a> {
7032
7024
};
7033
7025
}
7034
7026
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
+ };
7036
7032
7037
7033
Ok(CreateTableConfiguration {
7038
7034
partition_by,
@@ -7055,11 +7051,19 @@ impl<'a> Parser<'a> {
7055
7051
Keyword::CHARSET,
7056
7052
Keyword::COLLATE,
7057
7053
Keyword::INSERT_METHOD,
7054
+ Keyword::COMMENT,
7058
7055
]) {
7059
- let _ = self.consume_token(&Token::Eq);
7056
+ let has_eq = self.consume_token(&Token::Eq);
7060
7057
let value = self.next_token();
7061
7058
7062
7059
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
+ }
7063
7067
(Keyword::AUTO_INCREMENT, Token::Number(n, l)) => {
7064
7068
// validation
7065
7069
let _ = Some(Self::parse::<u32>(n.clone(), value.span.start)?);
0 commit comments