wqc200 commented on a change in pull request #7916:
URL: https://github.com/apache/arrow/pull/7916#discussion_r470619153
##########
File path: rust/datafusion/src/sql/parser.rs
##########
@@ -77,20 +77,20 @@ pub struct DFParser {
impl DFParser {
/// Parse the specified tokens
- pub fn new(sql: &str) -> Result<Self, ParserError> {
- let dialect = GenericDialect {};
- let mut tokenizer = Tokenizer::new(&dialect, sql);
+ pub fn new(sql: &str, dialect: &dyn Dialect) -> Result<Self, ParserError> {
+ let mut tokenizer = Tokenizer::new(dialect, sql);
let tokens = tokenizer.tokenize()?;
Ok(DFParser {
parser: Parser::new(tokens),
})
}
/// Parse a SQL statement and produce a set of statements
- pub fn parse_sql(sql: &str) -> Result<Vec<Statement>, ParserError> {
- let mut tokenizer = Tokenizer::new(&GenericDialect {}, &sql);
- tokenizer.tokenize()?;
- let mut parser = DFParser::new(sql)?;
+ pub fn parse_sql(
+ sql: &str,
+ dialect: &dyn Dialect,
Review comment:
I think dialect is an important optional parameter and will only be used
when initializing, so I think it should be entered in the entry
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]