mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-26 15:39:12 +00:00
Support single line comments starting with '#' for Hive (#1654)
This commit is contained in:
parent
c808c4e4fd
commit
6507484697
2 changed files with 4 additions and 2 deletions
|
@ -40,13 +40,13 @@ use serde::{Deserialize, Serialize};
|
||||||
#[cfg(feature = "visitor")]
|
#[cfg(feature = "visitor")]
|
||||||
use sqlparser_derive::{Visit, VisitMut};
|
use sqlparser_derive::{Visit, VisitMut};
|
||||||
|
|
||||||
use crate::ast::DollarQuotedString;
|
|
||||||
use crate::dialect::Dialect;
|
use crate::dialect::Dialect;
|
||||||
use crate::dialect::{
|
use crate::dialect::{
|
||||||
BigQueryDialect, DuckDbDialect, GenericDialect, MySqlDialect, PostgreSqlDialect,
|
BigQueryDialect, DuckDbDialect, GenericDialect, MySqlDialect, PostgreSqlDialect,
|
||||||
SnowflakeDialect,
|
SnowflakeDialect,
|
||||||
};
|
};
|
||||||
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
use crate::keywords::{Keyword, ALL_KEYWORDS, ALL_KEYWORDS_INDEX};
|
||||||
|
use crate::{ast::DollarQuotedString, dialect::HiveDialect};
|
||||||
|
|
||||||
/// SQL Token enumeration
|
/// SQL Token enumeration
|
||||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
|
||||||
|
@ -1372,7 +1372,8 @@ impl<'a> Tokenizer<'a> {
|
||||||
}
|
}
|
||||||
'{' => self.consume_and_return(chars, Token::LBrace),
|
'{' => self.consume_and_return(chars, Token::LBrace),
|
||||||
'}' => self.consume_and_return(chars, Token::RBrace),
|
'}' => self.consume_and_return(chars, Token::RBrace),
|
||||||
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect | MySqlDialect) => {
|
'#' if dialect_of!(self is SnowflakeDialect | BigQueryDialect | MySqlDialect | HiveDialect) =>
|
||||||
|
{
|
||||||
chars.next(); // consume the '#', starting a snowflake single-line comment
|
chars.next(); // consume the '#', starting a snowflake single-line comment
|
||||||
let comment = self.tokenize_single_line_comment(chars);
|
let comment = self.tokenize_single_line_comment(chars);
|
||||||
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
Ok(Some(Token::Whitespace(Whitespace::SingleLineComment {
|
||||||
|
|
|
@ -10423,6 +10423,7 @@ fn test_comment_hash_syntax() {
|
||||||
Box::new(BigQueryDialect {}),
|
Box::new(BigQueryDialect {}),
|
||||||
Box::new(SnowflakeDialect {}),
|
Box::new(SnowflakeDialect {}),
|
||||||
Box::new(MySqlDialect {}),
|
Box::new(MySqlDialect {}),
|
||||||
|
Box::new(HiveDialect {}),
|
||||||
]);
|
]);
|
||||||
let sql = r#"
|
let sql = r#"
|
||||||
# comment
|
# comment
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue