mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-28 01:44:07 +00:00
fix: export all methods of parser (#397)
This commit is contained in:
parent
d4e6ef597a
commit
929ef2a4b8
1 changed files with 21 additions and 19 deletions
|
@ -1716,7 +1716,7 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_columns(&mut self) -> Result<(Vec<ColumnDef>, Vec<TableConstraint>), ParserError> {
|
||||
pub fn parse_columns(&mut self) -> Result<(Vec<ColumnDef>, Vec<TableConstraint>), ParserError> {
|
||||
let mut columns = vec![];
|
||||
let mut constraints = vec![];
|
||||
if !self.consume_token(&Token::LParen) || self.consume_token(&Token::RParen) {
|
||||
|
@ -1743,7 +1743,7 @@ impl<'a> Parser<'a> {
|
|||
Ok((columns, constraints))
|
||||
}
|
||||
|
||||
fn parse_column_def(&mut self) -> Result<ColumnDef, ParserError> {
|
||||
pub fn parse_column_def(&mut self) -> Result<ColumnDef, ParserError> {
|
||||
let name = self.parse_identifier()?;
|
||||
let data_type = self.parse_data_type()?;
|
||||
let collation = if self.parse_keyword(Keyword::COLLATE) {
|
||||
|
@ -2099,11 +2099,11 @@ impl<'a> Parser<'a> {
|
|||
|
||||
/// Parse a tab separated values in
|
||||
/// COPY payload
|
||||
fn parse_tsv(&mut self) -> Vec<Option<String>> {
|
||||
pub fn parse_tsv(&mut self) -> Vec<Option<String>> {
|
||||
self.parse_tab_value()
|
||||
}
|
||||
|
||||
fn parse_tab_value(&mut self) -> Vec<Option<String>> {
|
||||
pub fn parse_tab_value(&mut self) -> Vec<Option<String>> {
|
||||
let mut values = vec![];
|
||||
let mut content = String::from("");
|
||||
while let Some(t) = self.next_token_no_skip() {
|
||||
|
@ -2135,7 +2135,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
/// Parse a literal value (numbers, strings, date/time, booleans)
|
||||
fn parse_value(&mut self) -> Result<Value, ParserError> {
|
||||
pub fn parse_value(&mut self) -> Result<Value, ParserError> {
|
||||
match self.next_token() {
|
||||
Token::Word(w) => match w.keyword {
|
||||
Keyword::TRUE => Ok(Value::Boolean(true)),
|
||||
|
@ -2540,7 +2540,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
/// Parse a CTE (`alias [( col1, col2, ... )] AS (subquery)`)
|
||||
fn parse_cte(&mut self) -> Result<Cte, ParserError> {
|
||||
pub fn parse_cte(&mut self) -> Result<Cte, ParserError> {
|
||||
let name = self.parse_identifier()?;
|
||||
|
||||
let mut cte = if self.parse_keyword(Keyword::AS) {
|
||||
|
@ -2583,7 +2583,7 @@ impl<'a> Parser<'a> {
|
|||
/// subquery ::= query_body [ order_by_limit ]
|
||||
/// set_operation ::= query_body { 'UNION' | 'EXCEPT' | 'INTERSECT' } [ 'ALL' ] query_body
|
||||
/// ```
|
||||
fn parse_query_body(&mut self, precedence: u8) -> Result<SetExpr, ParserError> {
|
||||
pub fn parse_query_body(&mut self, precedence: u8) -> Result<SetExpr, ParserError> {
|
||||
// We parse the expression using a Pratt parser, as in `parse_expr()`.
|
||||
// Start by parsing a restricted SELECT or a `(subquery)`:
|
||||
let mut expr = if self.parse_keyword(Keyword::SELECT) {
|
||||
|
@ -2628,7 +2628,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(expr)
|
||||
}
|
||||
|
||||
fn parse_set_operator(&mut self, token: &Token) -> Option<SetOperator> {
|
||||
pub fn parse_set_operator(&mut self, token: &Token) -> Option<SetOperator> {
|
||||
match token {
|
||||
Token::Word(w) if w.keyword == Keyword::UNION => Some(SetOperator::Union),
|
||||
Token::Word(w) if w.keyword == Keyword::EXCEPT => Some(SetOperator::Except),
|
||||
|
@ -2827,7 +2827,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_show_create(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_show_create(&mut self) -> Result<Statement, ParserError> {
|
||||
let obj_type = match self.expect_one_of_keywords(&[
|
||||
Keyword::TABLE,
|
||||
Keyword::TRIGGER,
|
||||
|
@ -2851,7 +2851,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Statement::ShowCreate { obj_type, obj_name })
|
||||
}
|
||||
|
||||
fn parse_show_columns(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_show_columns(&mut self) -> Result<Statement, ParserError> {
|
||||
let extended = self.parse_keyword(Keyword::EXTENDED);
|
||||
let full = self.parse_keyword(Keyword::FULL);
|
||||
self.expect_one_of_keywords(&[Keyword::COLUMNS, Keyword::FIELDS])?;
|
||||
|
@ -2869,7 +2869,9 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_show_statement_filter(&mut self) -> Result<Option<ShowStatementFilter>, ParserError> {
|
||||
pub fn parse_show_statement_filter(
|
||||
&mut self,
|
||||
) -> Result<Option<ShowStatementFilter>, ParserError> {
|
||||
if self.parse_keyword(Keyword::LIKE) {
|
||||
Ok(Some(ShowStatementFilter::Like(
|
||||
self.parse_literal_string()?,
|
||||
|
@ -3101,7 +3103,7 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_join_constraint(&mut self, natural: bool) -> Result<JoinConstraint, ParserError> {
|
||||
pub fn parse_join_constraint(&mut self, natural: bool) -> Result<JoinConstraint, ParserError> {
|
||||
if natural {
|
||||
Ok(JoinConstraint::Natural)
|
||||
} else if self.parse_keyword(Keyword::ON) {
|
||||
|
@ -3139,7 +3141,7 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_grant_revoke_privileges_objects(
|
||||
pub fn parse_grant_revoke_privileges_objects(
|
||||
&mut self,
|
||||
) -> Result<(Privileges, GrantObjects), ParserError> {
|
||||
let privileges = if self.parse_keyword(Keyword::ALL) {
|
||||
|
@ -3200,7 +3202,7 @@ impl<'a> Parser<'a> {
|
|||
Ok((privileges, objects))
|
||||
}
|
||||
|
||||
fn parse_grant_permission(&mut self) -> Result<(Keyword, Option<Vec<Ident>>), ParserError> {
|
||||
pub fn parse_grant_permission(&mut self) -> Result<(Keyword, Option<Vec<Ident>>), ParserError> {
|
||||
if let Some(kw) = self.parse_one_of_keywords(&[
|
||||
Keyword::CONNECT,
|
||||
Keyword::CREATE,
|
||||
|
@ -3364,7 +3366,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Assignment { id, value })
|
||||
}
|
||||
|
||||
fn parse_function_args(&mut self) -> Result<FunctionArg, ParserError> {
|
||||
pub fn parse_function_args(&mut self) -> Result<FunctionArg, ParserError> {
|
||||
if self.peek_nth_token(1) == Token::RArrow {
|
||||
let name = self.parse_identifier()?;
|
||||
|
||||
|
@ -3583,13 +3585,13 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn parse_deallocate(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_deallocate(&mut self) -> Result<Statement, ParserError> {
|
||||
let prepare = self.parse_keyword(Keyword::PREPARE);
|
||||
let name = self.parse_identifier()?;
|
||||
Ok(Statement::Deallocate { name, prepare })
|
||||
}
|
||||
|
||||
fn parse_execute(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_execute(&mut self) -> Result<Statement, ParserError> {
|
||||
let name = self.parse_identifier()?;
|
||||
|
||||
let mut parameters = vec![];
|
||||
|
@ -3601,7 +3603,7 @@ impl<'a> Parser<'a> {
|
|||
Ok(Statement::Execute { name, parameters })
|
||||
}
|
||||
|
||||
fn parse_prepare(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_prepare(&mut self) -> Result<Statement, ParserError> {
|
||||
let name = self.parse_identifier()?;
|
||||
|
||||
let mut data_types = vec![];
|
||||
|
@ -3619,7 +3621,7 @@ impl<'a> Parser<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_comment(&mut self) -> Result<Statement, ParserError> {
|
||||
pub fn parse_comment(&mut self) -> Result<Statement, ParserError> {
|
||||
self.expect_keyword(Keyword::ON)?;
|
||||
let token = self.next_token();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue