pub struct Parser<'a>(pub(crate) &'a [TokenWithLocation]);
Tuple Fields§
§0: &'a [TokenWithLocation]
Implementations§
source§impl Parser<'_>
impl Parser<'_>
sourcefn peek_format_encode_format(&mut self) -> bool
fn peek_format_encode_format(&mut self) -> bool
Peek the next tokens to see if it is FORMAT
or ROW FORMAT
(for compatibility).
sourcepub fn parse_format_encode_with_connector(
&mut self,
connector: &str,
cdc_source_job: bool,
) -> PResult<CompatibleFormatEncode>
pub fn parse_format_encode_with_connector( &mut self, connector: &str, cdc_source_job: bool, ) -> PResult<CompatibleFormatEncode>
Parse the source schema. The behavior depends on the connector
type.
sourcepub fn parse_schema(&mut self) -> PResult<Option<FormatEncodeOptions>>
pub fn parse_schema(&mut self) -> PResult<Option<FormatEncodeOptions>>
Parse FORMAT ... ENCODE ... (...)
.
source§impl Parser<'_>
impl Parser<'_>
sourcepub fn parse_sql(sql: &str) -> Result<Vec<Statement>, ParserError>
pub fn parse_sql(sql: &str) -> Result<Vec<Statement>, ParserError>
Parse a SQL statement and produce an Abstract Syntax Tree (AST)
sourcepub fn parse_object_name_str(s: &str) -> Result<ObjectName, ParserError>
pub fn parse_object_name_str(s: &str) -> Result<ObjectName, ParserError>
Parse object name from a string.
sourcefn parse_statements(&mut self) -> PResult<Vec<Statement>>
fn parse_statements(&mut self) -> PResult<Vec<Statement>>
Parse a list of semicolon-separated statements.
sourcepub fn parse_statement(&mut self) -> PResult<Statement>
pub fn parse_statement(&mut self) -> PResult<Statement>
Parse a single top-level statement (such as SELECT, INSERT, CREATE, etc.), stopping before the statement separator, if any.
pub fn parse_truncate(&mut self) -> PResult<Statement>
pub fn parse_analyze(&mut self) -> PResult<Statement>
sourcepub fn parse_wildcard_or_expr(&mut self) -> PResult<WildcardOrExpr>
pub fn parse_wildcard_or_expr(&mut self) -> PResult<WildcardOrExpr>
Tries to parse a wildcard expression. If it is not a wildcard, parses an expression.
A wildcard expression either means:
- Selecting all fields from a struct. In this case, it is a
WildcardOrExpr::ExprQualifiedWildcard
. Similar toExpr::FieldIdentifier
, It must contain parentheses. - Selecting all columns from a table. In this case, it is a
WildcardOrExpr::QualifiedWildcard
or aWildcardOrExpr::Wildcard
.
sourcepub fn word_concat_wildcard_expr(
&mut self,
ident: Ident,
simple_wildcard_expr: WildcardOrExpr,
) -> PResult<WildcardOrExpr>
pub fn word_concat_wildcard_expr( &mut self, ident: Ident, simple_wildcard_expr: WildcardOrExpr, ) -> PResult<WildcardOrExpr>
Concats ident
and wildcard_expr
in ident.wildcard_expr
sourcepub fn expr_concat_wildcard_expr(
&mut self,
expr: Expr,
simple_wildcard_expr: WildcardOrExpr,
) -> PResult<WildcardOrExpr>
pub fn expr_concat_wildcard_expr( &mut self, expr: Expr, simple_wildcard_expr: WildcardOrExpr, ) -> PResult<WildcardOrExpr>
Concats expr
and wildcard_expr
in (expr).wildcard_expr
.
sourcepub fn parse_simple_wildcard_expr(
&mut self,
checkpoint: Self,
) -> PResult<WildcardOrExpr>
pub fn parse_simple_wildcard_expr( &mut self, checkpoint: Self, ) -> PResult<WildcardOrExpr>
Tries to parses a wildcard expression without any parentheses.
If wildcard is not found, go back to index
and parse an expression.
pub fn parse_except(&mut self) -> PResult<Option<Vec<Expr>>>
sourcepub fn parse_expr(&mut self) -> PResult<Expr>
pub fn parse_expr(&mut self) -> PResult<Expr>
Parse a new expression
sourcepub fn parse_subexpr(&mut self, precedence: Precedence) -> PResult<Expr>
pub fn parse_subexpr(&mut self, precedence: Precedence) -> PResult<Expr>
Parse tokens until the precedence changes
sourcepub fn parse_prefix(&mut self) -> PResult<Expr>
pub fn parse_prefix(&mut self) -> PResult<Expr>
Parse an expression prefix
fn parse_param(&mut self, param: String) -> PResult<Expr>
sourcepub fn parse_struct_selection(&mut self, expr: Expr) -> PResult<Expr>
pub fn parse_struct_selection(&mut self, expr: Expr) -> PResult<Expr>
Parses a field selection expression. See also Expr::FieldIdentifier
.
sourcepub fn parse_fields(&mut self) -> PResult<Vec<Ident>>
pub fn parse_fields(&mut self) -> PResult<Vec<Ident>>
Parses consecutive field identifiers after a period. i.e., .foo.bar.baz
pub fn parse_qualified_operator(&mut self) -> PResult<QualifiedOperator>
sourcepub fn parse_function(&mut self) -> PResult<Expr>
pub fn parse_function(&mut self) -> PResult<Expr>
Parse a function call.
pub fn parse_window_frame_units(&mut self) -> PResult<WindowFrameUnits>
pub fn parse_window_frame(&mut self) -> PResult<WindowFrame>
sourcepub fn parse_window_frame_bound(&mut self) -> PResult<WindowFrameBound>
pub fn parse_window_frame_bound(&mut self) -> PResult<WindowFrameBound>
Parse CURRENT ROW
or { <non-negative numeric | datetime | interval> | UNBOUNDED } { PRECEDING | FOLLOWING }
pub fn parse_window_frame_exclusion(&mut self) -> PResult<WindowFrameExclusion>
sourcefn parse_group_by_expr(&mut self) -> PResult<Expr>
fn parse_group_by_expr(&mut self) -> PResult<Expr>
parse a group by expr. a group by expr can be one of group sets, roll up, cube, or simple expr.
sourcefn parse_tuple(
&mut self,
lift_singleton: bool,
allow_empty: bool,
) -> PResult<Vec<Expr>>
fn parse_tuple( &mut self, lift_singleton: bool, allow_empty: bool, ) -> PResult<Vec<Expr>>
parse a tuple with (
and )
.
If lift_singleton
is true, then a singleton tuple is lifted to a tuple of length 1,
otherwise it will fail. If allow_empty
is true, then an empty tuple is allowed.
pub fn parse_case_expr(&mut self) -> PResult<Expr>
sourcepub fn parse_cast_expr(&mut self) -> PResult<Expr>
pub fn parse_cast_expr(&mut self) -> PResult<Expr>
Parse a SQL CAST function e.g. CAST(expr AS FLOAT)
sourcepub fn parse_try_cast_expr(&mut self) -> PResult<Expr>
pub fn parse_try_cast_expr(&mut self) -> PResult<Expr>
Parse a SQL TRY_CAST function e.g. TRY_CAST(expr AS FLOAT)
sourcepub fn parse_exists_expr(&mut self) -> PResult<Expr>
pub fn parse_exists_expr(&mut self) -> PResult<Expr>
Parse a SQL EXISTS expression e.g. WHERE EXISTS(SELECT ...)
.
pub fn parse_extract_expr(&mut self) -> PResult<Expr>
pub fn parse_substring_expr(&mut self) -> PResult<Expr>
sourcepub fn parse_position_expr(&mut self) -> PResult<Expr>
pub fn parse_position_expr(&mut self) -> PResult<Expr>
POSITION(<expr> IN <expr>)
sourcepub fn parse_overlay_expr(&mut self) -> PResult<Expr>
pub fn parse_overlay_expr(&mut self) -> PResult<Expr>
OVERLAY(<expr> PLACING <expr> FROM <expr> [ FOR <expr> ])
sourcepub fn parse_trim_expr(&mut self) -> PResult<Expr>
pub fn parse_trim_expr(&mut self) -> PResult<Expr>
TRIM ([WHERE] ['text'] FROM 'text')
TRIM ([WHERE] [FROM] 'text' [, 'text'])
pub fn parse_trim_where(&mut self) -> PResult<TrimWhereField>
sourcepub fn parse_array_expr(&mut self) -> PResult<Expr>
pub fn parse_array_expr(&mut self) -> PResult<Expr>
Parses an array expression [ex1, ex2, ..]
fn parse_array_inner( &mut self, depth: usize, expected_depth: &mut Option<usize>, ) -> PResult<Vec<Expr>>
sourcepub fn parse_map_expr(&mut self) -> PResult<Expr>
pub fn parse_map_expr(&mut self) -> PResult<Expr>
Parses a map expression MAP {k1:v1, k2:v2, ..}
pub fn parse_date_time_field(&mut self) -> PResult<DateTimeField>
pub fn parse_date_time_field_in_extract(&mut self) -> PResult<String>
sourcepub fn parse_literal_interval(&mut self) -> PResult<Expr>
pub fn parse_literal_interval(&mut self) -> PResult<Expr>
Parse an INTERVAL literal.
Some syntactically valid intervals:
INTERVAL '1' DAY
INTERVAL '1-1' YEAR TO MONTH
INTERVAL '1' SECOND
INTERVAL '1:1:1.1' HOUR (5) TO SECOND (5)
INTERVAL '1.1' SECOND (2, 2)
INTERVAL '1:1' HOUR (5) TO MINUTE (5)
Note that we do not currently attempt to parse the quoted value.
sourcepub fn parse_infix(
&mut self,
expr: Expr,
precedence: Precedence,
) -> PResult<Expr>
pub fn parse_infix( &mut self, expr: Expr, precedence: Precedence, ) -> PResult<Expr>
Parse an operator following an expression
sourcepub fn parse_escape(&mut self) -> PResult<Option<EscapeChar>>
pub fn parse_escape(&mut self) -> PResult<Option<EscapeChar>>
parse the ESCAPE CHAR portion of LIKE, ILIKE, and SIMILAR TO
sourcepub fn parse_array_index(&mut self, expr: Expr) -> PResult<Expr>
pub fn parse_array_index(&mut self, expr: Expr) -> PResult<Expr>
We parse both array[1,9][1]
, array[1,9][1:2]
, array[1,9][:2]
, array[1,9][1:]
and
array[1,9][:]
in this function.
sourcepub fn parse_is_json(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
pub fn parse_is_json(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
Parses the optional constraints following the IS [NOT] JSON
predicate
sourcepub fn parse_in(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
pub fn parse_in(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
Parses the parens following the [ NOT ] IN
operator
sourcepub fn parse_between(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
pub fn parse_between(&mut self, expr: Expr, negated: bool) -> PResult<Expr>
Parses BETWEEN <low> AND <high>
, assuming the BETWEEN
keyword was already consumed
sourcepub fn parse_pg_cast(&mut self, expr: Expr) -> PResult<Expr>
pub fn parse_pg_cast(&mut self, expr: Expr) -> PResult<Expr>
Parse a postgresql casting style which is in the form of expr::datatype
sourcepub fn get_next_precedence(&self) -> PResult<Precedence>
pub fn get_next_precedence(&self) -> PResult<Precedence>
Get the precedence of the next token
sourcepub fn peek_token(&self) -> TokenWithLocation
pub fn peek_token(&self) -> TokenWithLocation
Return the first non-whitespace token that has not yet been processed (or None if reached end-of-file)
sourcepub fn peek_nth_token(&self, n: usize) -> TokenWithLocation
pub fn peek_nth_token(&self, n: usize) -> TokenWithLocation
Return nth non-whitespace token that has not yet been processed
sourcepub fn next_token(&mut self) -> TokenWithLocation
pub fn next_token(&mut self) -> TokenWithLocation
Return the first non-whitespace token that has not yet been processed (or None if reached end-of-file) and mark it as processed. OK to call repeatedly after reaching EOF.
sourcepub fn next_token_no_skip(&mut self) -> Option<&TokenWithLocation>
pub fn next_token_no_skip(&mut self) -> Option<&TokenWithLocation>
Return the first unprocessed token, possibly whitespace.
sourcepub fn expected<T>(&self, expected: &str) -> PResult<T>
pub fn expected<T>(&self, expected: &str) -> PResult<T>
Report an expected error at the current position.
sourcepub fn expected_at<T>(&mut self, checkpoint: Self, expected: &str) -> PResult<T>
pub fn expected_at<T>(&mut self, checkpoint: Self, expected: &str) -> PResult<T>
Revert the parser to a previous position and report an expected error.
sourcepub fn parse_word(&mut self, expected: &str) -> bool
pub fn parse_word(&mut self, expected: &str) -> bool
Check if the expected match is the next token. The equality check is case-insensitive.
sourcepub fn parse_keyword(&mut self, expected: Keyword) -> bool
pub fn parse_keyword(&mut self, expected: Keyword) -> bool
Look for an expected keyword and consume it if it exists
sourcepub fn parse_keywords(&mut self, keywords: &[Keyword]) -> bool
pub fn parse_keywords(&mut self, keywords: &[Keyword]) -> bool
Look for an expected sequence of keywords and consume them if they exist
sourcepub fn parse_one_of_keywords(&mut self, keywords: &[Keyword]) -> Option<Keyword>
pub fn parse_one_of_keywords(&mut self, keywords: &[Keyword]) -> Option<Keyword>
Look for one of the given keywords and return the one that matches.
pub fn peek_nth_any_of_keywords( &mut self, n: usize, keywords: &[Keyword], ) -> bool
sourcepub fn expect_one_of_keywords(
&mut self,
keywords: &[Keyword],
) -> PResult<Keyword>
pub fn expect_one_of_keywords( &mut self, keywords: &[Keyword], ) -> PResult<Keyword>
Bail out if the current token is not one of the expected keywords, or consume it if it is
sourcepub fn expect_keyword(&mut self, expected: Keyword) -> PResult<()>
pub fn expect_keyword(&mut self, expected: Keyword) -> PResult<()>
Bail out if the current token is not an expected keyword, or consume it if it is
sourcepub fn expect_keywords(&mut self, expected: &[Keyword]) -> PResult<()>
pub fn expect_keywords(&mut self, expected: &[Keyword]) -> PResult<()>
Bail out if the following tokens are not the expected sequence of keywords, or consume them if they are.
sourcepub fn consume_token(&mut self, expected: &Token) -> bool
pub fn consume_token(&mut self, expected: &Token) -> bool
Consume the next token if it matches the expected token, otherwise return false
sourcepub fn expect_token(&mut self, expected: &Token) -> PResult<()>
pub fn expect_token(&mut self, expected: &Token) -> PResult<()>
Bail out if the current token is not an expected keyword, or consume it if it is
sourcepub fn parse_comma_separated<T, F>(&mut self, f: F) -> PResult<Vec<T>>where
F: FnMut(&mut Self) -> PResult<T>,
pub fn parse_comma_separated<T, F>(&mut self, f: F) -> PResult<Vec<T>>where
F: FnMut(&mut Self) -> PResult<T>,
Parse a comma-separated list of 1+ items accepted by F
sourcefn maybe_parse<T, F>(&mut self, f: F) -> Option<T>where
F: FnMut(&mut Self) -> PResult<T>,
fn maybe_parse<T, F>(&mut self, f: F) -> Option<T>where
F: FnMut(&mut Self) -> PResult<T>,
Run a parser method f
, reverting back to the current position
if unsuccessful.
sourcepub fn parse_all_or_distinct(&mut self) -> PResult<bool>
pub fn parse_all_or_distinct(&mut self) -> PResult<bool>
Parse either ALL
or DISTINCT
. Returns true
if DISTINCT
is parsed and results in a
ParserError
if both ALL
and DISTINCT
are fround.
sourcepub fn parse_all_or_distinct_on(&mut self) -> PResult<Distinct>
pub fn parse_all_or_distinct_on(&mut self) -> PResult<Distinct>
Parse either ALL
or DISTINCT
or DISTINCT ON (<expr>)
.
sourcepub fn parse_create(&mut self) -> PResult<Statement>
pub fn parse_create(&mut self) -> PResult<Statement>
Parse a SQL CREATE statement
pub fn parse_create_schema(&mut self) -> PResult<Statement>
pub fn parse_create_database(&mut self) -> PResult<Statement>
pub fn parse_create_view( &mut self, materialized: bool, or_replace: bool, ) -> PResult<Statement>
pub fn parse_create_source( &mut self, _or_replace: bool, temporary: bool, ) -> PResult<Statement>
pub fn parse_create_sink(&mut self, _or_replace: bool) -> PResult<Statement>
pub fn parse_create_subscription( &mut self, _or_replace: bool, ) -> PResult<Statement>
pub fn parse_create_connection(&mut self) -> PResult<Statement>
pub fn parse_create_function( &mut self, or_replace: bool, temporary: bool, ) -> PResult<Statement>
fn parse_create_aggregate(&mut self, or_replace: bool) -> PResult<Statement>
pub fn parse_declare(&mut self) -> PResult<Statement>
pub fn parse_fetch_cursor(&mut self) -> PResult<Statement>
pub fn parse_close_cursor(&mut self) -> PResult<Statement>
fn parse_table_column_def(&mut self) -> PResult<TableColumnDef>
fn parse_function_arg(&mut self) -> PResult<OperateFunctionArg>
fn parse_create_function_body(&mut self) -> PResult<CreateFunctionBody>
fn parse_create_function_using(&mut self) -> PResult<CreateFunctionUsing>
fn parse_create_user(&mut self) -> PResult<Statement>
fn parse_create_secret(&mut self) -> PResult<Statement>
pub fn parse_with_properties(&mut self) -> PResult<Vec<SqlOption>>
pub fn parse_discard(&mut self) -> PResult<Statement>
pub fn parse_drop(&mut self) -> PResult<Statement>
sourcefn parse_drop_function(&mut self) -> PResult<Statement>
fn parse_drop_function(&mut self) -> PResult<Statement>
DROP FUNCTION [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
sourcefn parse_drop_aggregate(&mut self) -> PResult<Statement>
fn parse_drop_aggregate(&mut self) -> PResult<Statement>
DROP AGGREGATE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ] [, ...]
[ CASCADE | RESTRICT ]
fn parse_function_desc(&mut self) -> PResult<FunctionDesc>
pub fn parse_create_index(&mut self, unique: bool) -> PResult<Statement>
pub fn parse_with_version_column(&mut self) -> PResult<Option<String>>
pub fn parse_on_conflict(&mut self) -> PResult<Option<OnConflict>>
pub fn parse_create_table( &mut self, or_replace: bool, temporary: bool, ) -> PResult<Statement>
pub fn parse_include_options(&mut self) -> PResult<IncludeOption>
pub fn parse_columns_with_watermark( &mut self, ) -> PResult<(Vec<ColumnDef>, Vec<TableConstraint>, Vec<SourceWatermark>, Option<usize>)>
fn parse_column_def(&mut self) -> PResult<ColumnDef>
pub fn parse_optional_column_option(&mut self) -> PResult<Option<ColumnOption>>
pub fn parse_handle_conflict_behavior(&mut self) -> PResult<Option<OnConflict>>
pub fn parse_referential_action(&mut self) -> PResult<ReferentialAction>
pub fn parse_optional_watermark(&mut self) -> PResult<Option<SourceWatermark>>
pub fn parse_optional_table_constraint( &mut self, ) -> PResult<Option<TableConstraint>>
pub fn parse_options_with_preceding_keyword( &mut self, keyword: Keyword, ) -> PResult<Vec<SqlOption>>
pub fn parse_options(&mut self) -> PResult<Vec<SqlOption>>
pub fn parse_options_inner(&mut self) -> PResult<Vec<SqlOption>>
pub fn parse_sql_option(&mut self) -> PResult<SqlOption>
pub fn parse_since(&mut self) -> PResult<Since>
pub fn parse_emit_mode(&mut self) -> PResult<Option<EmitMode>>
pub fn parse_alter(&mut self) -> PResult<Statement>
pub fn parse_alter_database(&mut self) -> PResult<Statement>
pub fn parse_alter_schema(&mut self) -> PResult<Statement>
pub fn parse_alter_user(&mut self) -> PResult<Statement>
pub fn parse_alter_table(&mut self) -> PResult<Statement>
sourcepub fn parse_alter_backfill_rate_limit(&mut self) -> PResult<Option<i32>>
pub fn parse_alter_backfill_rate_limit(&mut self) -> PResult<Option<i32>>
BACKFILL_RATE_LIMIT = default | NUMBER BACKFILL_RATE_LIMIT TO default | NUMBER
sourcepub fn parse_alter_source_rate_limit(
&mut self,
is_table: bool,
) -> PResult<Option<i32>>
pub fn parse_alter_source_rate_limit( &mut self, is_table: bool, ) -> PResult<Option<i32>>
SOURCE_RATE_LIMIT = default | NUMBER SOURCE_RATE_LIMIT TO default | NUMBER
pub fn parse_alter_index(&mut self) -> PResult<Statement>
pub fn parse_alter_view(&mut self, materialized: bool) -> PResult<Statement>
pub fn parse_alter_sink(&mut self) -> PResult<Statement>
pub fn parse_alter_subscription(&mut self) -> PResult<Statement>
pub fn parse_alter_source(&mut self) -> PResult<Statement>
pub fn parse_alter_function(&mut self) -> PResult<Statement>
pub fn parse_alter_connection(&mut self) -> PResult<Statement>
pub fn parse_alter_system(&mut self) -> PResult<Statement>
sourcepub fn parse_copy(&mut self) -> PResult<Statement>
pub fn parse_copy(&mut self) -> PResult<Statement>
Parse a copy statement
fn parse_tab_value(&mut self) -> Vec<Option<String>>
sourcepub fn parse_value(&mut self) -> PResult<Value>
pub fn parse_value(&mut self) -> PResult<Value>
Parse a literal value (numbers, strings, date/time, booleans)
fn parse_set_variable(&mut self) -> PResult<SetVariableValue>
pub fn parse_number_value(&mut self) -> PResult<String>
sourcepub fn parse_literal_uint(&mut self) -> PResult<u64>
pub fn parse_literal_uint(&mut self) -> PResult<u64>
Parse an unsigned literal integer/long
pub fn parse_function_definition(&mut self) -> PResult<FunctionDefinition>
sourcepub fn parse_literal_string(&mut self) -> PResult<String>
pub fn parse_literal_string(&mut self) -> PResult<String>
Parse a literal string
sourcepub fn parse_map_key(&mut self) -> PResult<Expr>
pub fn parse_map_key(&mut self) -> PResult<Expr>
Parse a map key string
sourcepub fn parse_data_type(&mut self) -> PResult<DataType>
pub fn parse_data_type(&mut self) -> PResult<DataType>
Parse a SQL datatype (in the context of a CREATE TABLE statement for example)
sourcepub fn parse_optional_alias(
&mut self,
reserved_kwds: &[Keyword],
) -> PResult<Option<Ident>>
pub fn parse_optional_alias( &mut self, reserved_kwds: &[Keyword], ) -> PResult<Option<Ident>>
Parse AS identifier
(or simply identifier
if it’s not a reserved keyword)
Some examples with aliases: SELECT 1 foo
, SELECT COUNT(*) AS cnt
,
SELECT ... FROM t1 foo, t2 bar
, SELECT ... FROM (...) AS bar
sourcepub fn parse_optional_table_alias(
&mut self,
reserved_kwds: &[Keyword],
) -> PResult<Option<TableAlias>>
pub fn parse_optional_table_alias( &mut self, reserved_kwds: &[Keyword], ) -> PResult<Option<TableAlias>>
Parse AS identifier
when the AS is describing a table-valued object,
like in ... FROM generate_series(1, 10) AS t (col)
. In this case
the alias is allowed to optionally name the columns in the table, in
addition to the table itself.
sourcepub fn parse_as_of(&mut self) -> PResult<AsOf>
pub fn parse_as_of(&mut self) -> PResult<AsOf>
syntax FOR SYSTEM_TIME AS OF PROCTIME()
is used for temporal join.
sourcepub fn parse_object_name(&mut self) -> PResult<ObjectName>
pub fn parse_object_name(&mut self) -> PResult<ObjectName>
Parse a possibly qualified, possibly quoted identifier, e.g.
foo
or `myschema.“table”
sourcepub fn parse_identifiers_non_keywords(&mut self) -> PResult<Vec<Ident>>
pub fn parse_identifiers_non_keywords(&mut self) -> PResult<Vec<Ident>>
Parse identifiers strictly i.e. don’t parse keywords
sourcepub fn parse_identifiers(&mut self) -> PResult<Vec<Ident>>
pub fn parse_identifiers(&mut self) -> PResult<Vec<Ident>>
Parse identifiers
sourcepub fn parse_identifier(&mut self) -> PResult<Ident>
pub fn parse_identifier(&mut self) -> PResult<Ident>
Parse a simple one-word identifier (possibly quoted, possibly a keyword)
sourcepub fn parse_identifier_non_reserved(&mut self) -> PResult<Ident>
pub fn parse_identifier_non_reserved(&mut self) -> PResult<Ident>
Parse a simple one-word identifier (possibly quoted, possibly a non-reserved keyword)
sourcepub fn parse_parenthesized_column_list(
&mut self,
optional: IsOptional,
) -> PResult<Vec<Ident>>
pub fn parse_parenthesized_column_list( &mut self, optional: IsOptional, ) -> PResult<Vec<Ident>>
Parse a parenthesized comma-separated list of unqualified, possibly quoted identifiers
pub fn parse_returning( &mut self, optional: IsOptional, ) -> PResult<Vec<SelectItem>>
pub fn parse_row_expr(&mut self) -> PResult<Expr>
sourcepub fn parse_token_wrapped_exprs(
&mut self,
left: &Token,
right: &Token,
) -> PResult<Vec<Expr>>
pub fn parse_token_wrapped_exprs( &mut self, left: &Token, right: &Token, ) -> PResult<Vec<Expr>>
Parse a comma-separated list (maybe empty) from a wrapped expression
pub fn parse_optional_precision(&mut self) -> PResult<Option<u64>>
pub fn parse_optional_precision_scale( &mut self, ) -> PResult<(Option<u64>, Option<u64>)>
pub fn parse_delete(&mut self) -> PResult<Statement>
pub fn parse_optional_boolean(&mut self, default: bool) -> bool
pub fn parse_explain(&mut self) -> PResult<Statement>
sourcepub fn parse_query(&mut self) -> PResult<Query>
pub fn parse_query(&mut self) -> PResult<Query>
Parse a query expression, i.e. a SELECT
statement optionally
preceded with some WITH
CTE declarations and optionally followed
by ORDER BY
. Unlike some other parse_… methods, this one doesn’t
expect the initial keyword to be already consumed
sourcefn parse_cte(&mut self) -> PResult<Cte>
fn parse_cte(&mut self) -> PResult<Cte>
Parse a CTE (alias [( col1, col2, ... )] AS (subquery)
)
fn parse_cte_inner(&mut self) -> PResult<CteInner>
sourcefn parse_query_body(&mut self, precedence: u8) -> PResult<SetExpr>
fn parse_query_body(&mut self, precedence: u8) -> PResult<SetExpr>
Parse a “query body”, which is an expression with roughly the following grammar:
query_body ::= restricted_select | '(' subquery ')' | set_operation
restricted_select ::= 'SELECT' [expr_list] [ from ] [ where ] [ groupby_having ]
subquery ::= query_body [ order_by_limit ]
set_operation ::= query_body { 'UNION' | 'EXCEPT' | 'INTERSECT' } [ 'ALL' ] query_body
fn parse_set_operator(&mut self, token: &Token) -> Option<SetOperator>
fn parse_corresponding(&mut self) -> PResult<Corresponding>
sourcepub fn parse_select(&mut self) -> PResult<Select>
pub fn parse_select(&mut self) -> PResult<Select>
Parse a restricted SELECT
statement (no CTEs / UNION
/ ORDER BY
),
assuming the initial SELECT
was already consumed
pub fn parse_set(&mut self) -> PResult<Statement>
sourcepub fn parse_show(&mut self) -> PResult<Statement>
pub fn parse_show(&mut self) -> PResult<Statement>
If have databases
,tables
,columns
,schemas
and materialized views
after show,
return Statement::ShowCommand
or Statement::ShowColumn
,
otherwise, return Statement::ShowVariable
.
pub fn parse_cancel_job(&mut self) -> PResult<Statement>
pub fn parse_kill_process(&mut self) -> PResult<Statement>
sourcepub fn parse_from_and_identifier(&mut self) -> PResult<Option<Ident>>
pub fn parse_from_and_identifier(&mut self) -> PResult<Option<Ident>>
Parser from schema
after show tables
and show materialized views
, if not conclude
from
then use default schema name.
sourcepub fn parse_show_create(&mut self) -> PResult<Statement>
pub fn parse_show_create(&mut self) -> PResult<Statement>
Parse object type and name after show create
.
pub fn parse_show_statement_filter( &mut self, ) -> PResult<Option<ShowStatementFilter>>
pub fn parse_table_and_joins(&mut self) -> PResult<TableWithJoins>
sourcepub fn parse_table_factor(&mut self) -> PResult<TableFactor>
pub fn parse_table_factor(&mut self) -> PResult<TableFactor>
A table name or a parenthesized subquery, followed by optional [AS] alias
pub fn parse_derived_table_factor( &mut self, lateral: IsLateral, ) -> PResult<TableFactor>
fn parse_join_constraint(&mut self, natural: bool) -> PResult<JoinConstraint>
sourcepub fn parse_grant(&mut self) -> PResult<Statement>
pub fn parse_grant(&mut self) -> PResult<Statement>
Parse a GRANT statement.
fn parse_grant_revoke_privileges_objects( &mut self, ) -> PResult<(Privileges, GrantObjects)>
fn parse_grant_permission(&mut self) -> PResult<(Keyword, Option<Vec<Ident>>)>
sourcepub fn parse_revoke(&mut self) -> PResult<Statement>
pub fn parse_revoke(&mut self) -> PResult<Statement>
Parse a REVOKE statement
sourcepub fn parse_insert(&mut self) -> PResult<Statement>
pub fn parse_insert(&mut self) -> PResult<Statement>
Parse an INSERT statement
pub fn parse_update(&mut self) -> PResult<Statement>
sourcepub fn parse_assignment(&mut self) -> PResult<Assignment>
pub fn parse_assignment(&mut self) -> PResult<Assignment>
Parse a var = expr
assignment, used in an UPDATE statement
sourcefn parse_function_args(&mut self) -> PResult<(bool, FunctionArg)>
fn parse_function_args(&mut self) -> PResult<(bool, FunctionArg)>
Parse a [VARIADIC] name => expr
.
pub fn parse_argument_list(&mut self) -> PResult<FunctionArgList>
sourcepub fn parse_select_item(&mut self) -> PResult<SelectItem>
pub fn parse_select_item(&mut self) -> PResult<SelectItem>
Parse a comma-delimited list of projections after SELECT
sourcepub fn parse_order_by_expr(&mut self) -> PResult<OrderByExpr>
pub fn parse_order_by_expr(&mut self) -> PResult<OrderByExpr>
Parse an expression, optionally followed by ASC or DESC (used in ORDER BY)
sourcepub fn parse_limit(&mut self) -> PResult<Option<String>>
pub fn parse_limit(&mut self) -> PResult<Option<String>>
Parse a LIMIT clause
sourcepub fn parse_offset(&mut self) -> PResult<String>
pub fn parse_offset(&mut self) -> PResult<String>
Parse an OFFSET clause
sourcepub fn parse_fetch(&mut self) -> PResult<Fetch>
pub fn parse_fetch(&mut self) -> PResult<Fetch>
Parse a FETCH clause
pub fn parse_values(&mut self) -> PResult<Values>
pub fn parse_start_transaction(&mut self) -> PResult<Statement>
pub fn parse_begin(&mut self) -> PResult<Statement>
pub fn parse_transaction_modes(&mut self) -> PResult<Vec<TransactionMode>>
pub fn parse_commit(&mut self) -> PResult<Statement>
pub fn parse_rollback(&mut self) -> PResult<Statement>
pub fn parse_commit_rollback_chain(&mut self) -> PResult<bool>
fn parse_deallocate(&mut self) -> PResult<Statement>
fn parse_execute(&mut self) -> PResult<Statement>
fn parse_prepare(&mut self) -> PResult<Statement>
fn parse_comment(&mut self) -> PResult<Statement>
Trait Implementations§
source§impl<'a> Offset<CheckpointWrapper<'a>> for Parser<'a>
impl<'a> Offset<CheckpointWrapper<'a>> for Parser<'a>
source§fn offset_from(&self, start: &CheckpointWrapper<'a>) -> usize
fn offset_from(&self, start: &CheckpointWrapper<'a>) -> usize
source§impl<'a> Stream for Parser<'a>
impl<'a> Stream for Parser<'a>
source§type Checkpoint = CheckpointWrapper<'a>
type Checkpoint = CheckpointWrapper<'a>
source§type IterOffsets = <&'a [TokenWithLocation] as Stream>::IterOffsets
type IterOffsets = <&'a [TokenWithLocation] as Stream>::IterOffsets
source§type Token = <&'a [TokenWithLocation] as Stream>::Token
type Token = <&'a [TokenWithLocation] as Stream>::Token
source§fn iter_offsets(&self) -> Self::IterOffsets
fn iter_offsets(&self) -> Self::IterOffsets
source§fn eof_offset(&self) -> usize
fn eof_offset(&self) -> usize
source§fn next_token(&mut self) -> Option<Self::Token>
fn next_token(&mut self) -> Option<Self::Token>
source§fn offset_for<P>(&self, predicate: P) -> Option<usize>
fn offset_for<P>(&self, predicate: P) -> Option<usize>
source§fn offset_at(&self, tokens: usize) -> Result<usize, Needed>
fn offset_at(&self, tokens: usize) -> Result<usize, Needed>
tokens
into the stream Read moresource§fn next_slice(&mut self, offset: usize) -> Self::Slice
fn next_slice(&mut self, offset: usize) -> Self::Slice
source§fn checkpoint(&self) -> Self::Checkpoint
fn checkpoint(&self) -> Self::Checkpoint
source§fn reset(&mut self, checkpoint: &Self::Checkpoint)
fn reset(&mut self, checkpoint: &Self::Checkpoint)
Self::Checkpoint
] Read more§fn peek_token(&self) -> Option<(Self, Self::Token)>where
Self: Clone,
fn peek_token(&self) -> Option<(Self, Self::Token)>where
Self: Clone,
§fn peek_slice(&self, offset: usize) -> (Self, Self::Slice)where
Self: Clone,
fn peek_slice(&self, offset: usize) -> (Self, Self::Slice)where
Self: Clone,
§fn peek_finish(&self) -> (Self, Self::Slice)where
Self: Clone,
fn peek_finish(&self) -> (Self, Self::Slice)where
Self: Clone,
source§impl<'a> StreamIsPartial for Parser<'a>
impl<'a> StreamIsPartial for Parser<'a>
source§type PartialState = <&'a [TokenWithLocation] as StreamIsPartial>::PartialState
type PartialState = <&'a [TokenWithLocation] as StreamIsPartial>::PartialState
source§fn restore_partial(&mut self, state: Self::PartialState)
fn restore_partial(&mut self, state: Self::PartialState)
source§fn is_partial_supported() -> bool
fn is_partial_supported() -> bool
Stream
] is can ever be incomplete§fn is_partial(&self) -> bool
fn is_partial(&self) -> bool
Stream
] is currently incompletesource§impl UpdateSlice for Parser<'_>
impl UpdateSlice for Parser<'_>
source§fn update_slice(self, inner: Self::Slice) -> Self
fn update_slice(self, inner: Self::Slice) -> Self
Output
type to be used as Stream
impl<'a> Copy for Parser<'a>
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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