pub struct DFParser<'a> {
pub parser: Parser<'a>,
options: SqlParserOptions,
}Expand description
DataFusion SQL Parser based on [sqlparser]
Parses DataFusion’s SQL dialect, often delegating to [sqlparser]’s [Parser].
DataFusion mostly follows existing SQL dialects via
sqlparser. However, certain statements such as COPY and
CREATE EXTERNAL TABLE have special syntax in DataFusion. See
Statement for a list of this special syntax
Fields§
§parser: Parser<'a>§options: SqlParserOptionsImplementations§
Source§impl<'a> DFParser<'a>
impl<'a> DFParser<'a>
pub fn new(sql: &'a str) -> Result<Self, DataFusionError>
pub fn new_with_dialect( sql: &'a str, dialect: &'a dyn Dialect, ) -> Result<Self, DataFusionError>
Sourcepub fn parse_sql(sql: &'a str) -> Result<VecDeque<Statement>, DataFusionError>
pub fn parse_sql(sql: &'a str) -> Result<VecDeque<Statement>, DataFusionError>
Parse a sql string into one or Statements using the
[GenericDialect].
Sourcepub fn parse_sql_with_dialect(
sql: &str,
dialect: &dyn Dialect,
) -> Result<VecDeque<Statement>, DataFusionError>
pub fn parse_sql_with_dialect( sql: &str, dialect: &dyn Dialect, ) -> Result<VecDeque<Statement>, DataFusionError>
Parse a SQL string and produce one or more Statements with
with the specified dialect.
pub fn parse_sql_into_expr(sql: &str) -> Result<ExprWithAlias, DataFusionError>
pub fn parse_sql_into_expr_with_dialect( sql: &str, dialect: &dyn Dialect, ) -> Result<ExprWithAlias, DataFusionError>
Sourcepub fn parse_statements(
&mut self,
) -> Result<VecDeque<Statement>, DataFusionError>
pub fn parse_statements( &mut self, ) -> Result<VecDeque<Statement>, DataFusionError>
Parse a sql string into one or Statements
Sourcefn expected<T>(
&self,
expected: &str,
found: TokenWithSpan,
) -> Result<T, DataFusionError>
fn expected<T>( &self, expected: &str, found: TokenWithSpan, ) -> Result<T, DataFusionError>
Report an unexpected token
fn expect_token( &mut self, expected: &str, token: Token, ) -> Result<(), DataFusionError>
Sourcepub fn parse_statement(&mut self) -> Result<Statement, DataFusionError>
pub fn parse_statement(&mut self) -> Result<Statement, DataFusionError>
Parse a new expression
pub fn parse_expr(&mut self) -> Result<ExprWithAlias, DataFusionError>
Sourcepub fn parse_into_expr(&mut self) -> Result<ExprWithAlias, DataFusionError>
pub fn parse_into_expr(&mut self) -> Result<ExprWithAlias, DataFusionError>
Parses the entire SQL string into an expression.
In contrast to DFParser::parse_expr, this function will report an error if the input
contains any trailing, unparsed tokens.
Sourcefn parse_and_handle_statement(&mut self) -> Result<Statement, DataFusionError>
fn parse_and_handle_statement(&mut self) -> Result<Statement, DataFusionError>
Helper method to parse a statement and handle errors consistently, especially for recursion limits
Sourcepub fn parse_copy(&mut self) -> Result<Statement, DataFusionError>
pub fn parse_copy(&mut self) -> Result<Statement, DataFusionError>
Parse a SQL COPY TO statement
Sourcepub fn parse_option_key(&mut self) -> Result<String, DataFusionError>
pub fn parse_option_key(&mut self) -> Result<String, DataFusionError>
Parse the next token as a key name for an option list
Note this is different than parse_literal_string
because it allows keywords as well as other non words
Sourcepub fn parse_option_value(&mut self) -> Result<Value, DataFusionError>
pub fn parse_option_value(&mut self) -> Result<Value, DataFusionError>
Parse the next token as a value for an option list
Note this is different than parse_value as it allows any
word or keyword in this location.
Sourcepub fn parse_explain(&mut self) -> Result<Statement, DataFusionError>
pub fn parse_explain(&mut self) -> Result<Statement, DataFusionError>
Parse a SQL EXPLAIN
pub fn parse_explain_format( &mut self, ) -> Result<Option<String>, DataFusionError>
Sourcepub fn parse_create(&mut self) -> Result<Statement, DataFusionError>
pub fn parse_create(&mut self) -> Result<Statement, DataFusionError>
Parse a SQL CREATE statement handling CREATE EXTERNAL TABLE
fn parse_partitions(&mut self) -> Result<Vec<String>, DataFusionError>
Sourcepub fn parse_order_by_exprs(
&mut self,
) -> Result<Vec<OrderByExpr>, DataFusionError>
pub fn parse_order_by_exprs( &mut self, ) -> Result<Vec<OrderByExpr>, DataFusionError>
Parse the ordering clause of a CREATE EXTERNAL TABLE SQL statement
Sourcepub fn parse_order_by_expr(&mut self) -> Result<OrderByExpr, DataFusionError>
pub fn parse_order_by_expr(&mut self) -> Result<OrderByExpr, DataFusionError>
Parse an ORDER BY sub-expression optionally followed by ASC or DESC.
fn parse_columns( &mut self, ) -> Result<(Vec<ColumnDef>, Vec<TableConstraint>), DataFusionError>
fn parse_column_def(&mut self) -> Result<ColumnDef, DataFusionError>
fn parse_create_external_table( &mut self, unbounded: bool, or_replace: bool, ) -> Result<Statement, DataFusionError>
Sourcefn parse_file_format(&mut self) -> Result<String, DataFusionError>
fn parse_file_format(&mut self) -> Result<String, DataFusionError>
Parses the set of valid formats
Sourcefn parse_value_options(
&mut self,
) -> Result<Vec<(String, Value)>, DataFusionError>
fn parse_value_options( &mut self, ) -> Result<Vec<(String, Value)>, DataFusionError>
Parses (key value) style options into a map of String –> [Value].
This method supports keywords as key names as well as multiple value types such as Numbers as well as Strings.
Auto Trait Implementations§
impl<'a> Freeze for DFParser<'a>
impl<'a> !RefUnwindSafe for DFParser<'a>
impl<'a> !Send for DFParser<'a>
impl<'a> !Sync for DFParser<'a>
impl<'a> Unpin for DFParser<'a>
impl<'a> !UnwindSafe for DFParser<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more