Skip to content

Commit 6507484

Browse files
authored
Support single line comments starting with '#' for Hive (apache#1654)
1 parent c808c4e commit 6507484

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/tokenizer.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ use serde::{Deserialize, Serialize};
4040
#[cfg(feature = "visitor")]
4141
use sqlparser_derive::{Visit, VisitMut};
4242

43-
use crate::ast::DollarQuotedString;
4443
use crate::dialect::Dialect;
4544
use crate::dialect::{
4645
BigQueryDialect, DuckDbDialect, GenericDialect, MySqlDialect, PostgreSqlDialect,
4746
SnowflakeDialect,
4847
};
4948
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
49+
use crate::{ast::DollarQuotedString, dialect::HiveDialect};
5050

5151
/// SQL Token enumeration
5252
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
@@ -1372,7 +1372,8 @@ impl<'a> Tokenizer<'a> {
13721372
}
13731373
'{' => self.consume_and_return(chars, Token::LBrace),
13741374
'}' => self.consume_and_return(chars, Token::RBrace),
1375-
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect | MySqlDialect) => {
1375+
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect | MySqlDialect | HiveDialect) =>
1376+
{
13761377
chars.next(); // consume the '#', starting a snowflake single-line comment
13771378
let comment = self.tokenize_single_line_comment(chars);
13781379
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {

tests/sqlparser_common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10423,6 +10423,7 @@ fn test_comment_hash_syntax() {
1042310423
Box::new(BigQueryDialect {}),
1042410424
Box::new(SnowflakeDialect {}),
1042510425
Box::new(MySqlDialect {}),
10426+
Box::new(HiveDialect {}),
1042610427
]);
1042710428
let sql = r#"
1042810429
# comment

0 commit comments

Comments
 (0)