DFParser

Struct DFParser 

Source
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: SqlParserOptions

Implementations§

Source§

impl<'a> DFParser<'a>

Source

pub fn new(sql: &'a str) -> Result<Self, DataFusionError>

👎Deprecated since 46.0.0: DFParserBuilder
Source

pub fn new_with_dialect( sql: &'a str, dialect: &'a dyn Dialect, ) -> Result<Self, DataFusionError>

👎Deprecated since 46.0.0: DFParserBuilder
Source

pub fn parse_sql(sql: &'a str) -> Result<VecDeque<Statement>, DataFusionError>

Parse a sql string into one or Statements using the [GenericDialect].

Source

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.

Source

pub fn parse_sql_into_expr(sql: &str) -> Result<ExprWithAlias, DataFusionError>

Source

pub fn parse_sql_into_expr_with_dialect( sql: &str, dialect: &dyn Dialect, ) -> Result<ExprWithAlias, DataFusionError>

Source

pub fn parse_statements( &mut self, ) -> Result<VecDeque<Statement>, DataFusionError>

Parse a sql string into one or Statements

Source

fn expected<T>( &self, expected: &str, found: TokenWithSpan, ) -> Result<T, DataFusionError>

Report an unexpected token

Source

fn expect_token( &mut self, expected: &str, token: Token, ) -> Result<(), DataFusionError>

Source

pub fn parse_statement(&mut self) -> Result<Statement, DataFusionError>

Parse a new expression

Source

pub fn parse_expr(&mut self) -> Result<ExprWithAlias, DataFusionError>

Source

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.

Source

fn parse_and_handle_statement(&mut self) -> Result<Statement, DataFusionError>

Helper method to parse a statement and handle errors consistently, especially for recursion limits

Source

pub fn parse_copy(&mut self) -> Result<Statement, DataFusionError>

Parse a SQL COPY TO statement

Source

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

Source

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.

Source

pub fn parse_explain(&mut self) -> Result<Statement, DataFusionError>

Parse a SQL EXPLAIN

Source

pub fn parse_explain_format( &mut self, ) -> Result<Option<String>, DataFusionError>

Source

pub fn parse_create(&mut self) -> Result<Statement, DataFusionError>

Parse a SQL CREATE statement handling CREATE EXTERNAL TABLE

Source

fn parse_partitions(&mut self) -> Result<Vec<String>, DataFusionError>

Source

pub fn parse_order_by_exprs( &mut self, ) -> Result<Vec<OrderByExpr>, DataFusionError>

Parse the ordering clause of a CREATE EXTERNAL TABLE SQL statement

Source

pub fn parse_order_by_expr(&mut self) -> Result<OrderByExpr, DataFusionError>

Parse an ORDER BY sub-expression optionally followed by ASC or DESC.

Source

fn parse_columns( &mut self, ) -> Result<(Vec<ColumnDef>, Vec<TableConstraint>), DataFusionError>

Source

fn parse_column_def(&mut self) -> Result<ColumnDef, DataFusionError>

Source

fn parse_create_external_table( &mut self, unbounded: bool, or_replace: bool, ) -> Result<Statement, DataFusionError>

Source

fn parse_file_format(&mut self) -> Result<String, DataFusionError>

Parses the set of valid formats

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,