Skip to main content

Crate oxisql_parse

Crate oxisql_parse 

Source
Expand description

oxisql-parse — SQL parsing utilities for OxiSQL.

Re-exports the sqlparser AST types most commonly needed by OxiSQL backends and provides convenience functions for parsing, formatting, analysing, and dialect-specific handling of SQL statements.

§Quick start

use oxisql_parse::{parse, parse_one, is_read_only};

let stmts = parse("SELECT 1; SELECT 2").unwrap();
assert_eq!(stmts.len(), 2);

let stmt = parse_one("SELECT 42").unwrap();
assert!(is_read_only(&stmt));

Re-exports§

pub use optimizer::expr_util::canonical_hash;
pub use optimizer::expr_util::collect_colrefs;
pub use optimizer::expr_util::equi_key;
pub use optimizer::expr_util::find_common_subexprs;
pub use optimizer::expr_util::join_conjuncts;
pub use optimizer::expr_util::parse_expr;
pub use optimizer::expr_util::parse_predicate;
pub use optimizer::expr_util::render;
pub use optimizer::expr_util::split_conjuncts;
pub use optimizer::expr_util::ColRef;
pub use optimizer::CommonSubexprElimination;
pub use optimizer::ConstantFolding;
pub use optimizer::JoinAlgoHint;
pub use optimizer::JoinAlgorithmPass;
pub use optimizer::LimitPushThrough;
pub use optimizer::OptPass;
pub use optimizer::Optimizer;
pub use optimizer::PredicatePushdown;
pub use optimizer::PredicateSimplification;
pub use optimizer::ProjectionPruning;
pub use decorrelate::PlannerOptions;
pub use parameterize::parameterize;
pub use parameterize::ParameterizedSql;
pub use plan_cache::PlanCache;
pub use agg::extract_aggregates;
pub use agg::is_aggregate_expr;
pub use agg::AggFunc;
pub use agg::AggregateExpr;
pub use dml::plan_dml;
pub use dml::DmlPlan;
pub use validate::SchemaValidator;
pub use validate::ValidationError;
pub use cost::ColumnStats;
pub use cost::CostEstimate;
pub use cost::CostModel;
pub use cost::NodeCost;
pub use cost::TableStats;
pub use builder::QueryBuilder;
pub use plan::JoinType;
pub use plan::LogicalPlan;
pub use plan::SetOpType;
pub use plan::SortExpr;
pub use plan::WindowFunctionDef;
pub use planner::plan_query;
pub use planner::plan_statement;
pub use planner::plan_statement_with_opts;
pub use explain::explain;
pub use explain::explain_json;
pub use explain::explain_verbose;
pub use analysis::count_params;
pub use analysis::extract_columns;
pub use analysis::extract_tables;
pub use analysis::is_read_only;
pub use analysis::normalize;
pub use cache::ParseCache;

Modules§

agg
Aggregate function analysis helpers.
analysis
SQL statement analysis utilities: table extraction, column extraction, parameter counting, and SQL normalization.
builder
Fluent SQL query builder.
cache
LRU AST cache for parsed SQL statements.
cost
Query cost model for LogicalPlan trees.
decorrelate
Decorrelation of correlated subqueries into joins.
dml
DML planning helpers.
explain
Human-readable plan explanation for LogicalPlans.
optimizer
Rule-based SQL query optimizer for LogicalPlan.
parameterize
SQL literal parameterization: replace all literal values with ?.
plan
Logical plan type definitions for OxiSQL.
plan_cache
Parameterized-plan cache: an LRU cache keyed by the parameterized SQL template and a schema-generation counter.
planner
SQL statement planner: converts parsed AST statements to LogicalPlans.
validate
Schema-aware validation of LogicalPlan trees.

Structs§

GenericDialect
A permissive, general purpose Dialect, which parses a wide variety of SQL statements, from many different dialects.
MySqlDialect
A Dialect for MySQL
ObjectName
A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
PostgreSqlDialect
A Dialect for PostgreSQL
SQLiteDialect
A Dialect for SQLite

Enums§

Expr
An SQL expression of any type.
JoinConstraint
Represents how two tables are constrained in a join: ON, USING, NATURAL, or none.
SelectItem
One item of the comma-separated list following SELECT
SqlDialect
SQL dialect selection for parsing.
Statement
A top-level statement (SELECT, INSERT, CREATE, etc.)
TableFactor
A table name or a parenthesized subquery with an optional alias

Functions§

format
Convert a parsed AST statement back to a SQL string.
optimize
Apply the default four-pass optimizer to plan and return the result.
parse
Parse a SQL string into a list of Statements using the generic SQL dialect.
parse_mysql
Parse SQL using the MySQL dialect.
parse_one
Parse a SQL string that is expected to contain exactly one statement.
parse_one_with_dialect
Parse a single statement using a specific dialect.
parse_postgres
Parse SQL using the PostgreSQL dialect.
parse_sqlite
Parse SQL using the SQLite dialect.
parse_with_dialect
Parse a SQL string using a specific SqlDialect.
plan_query_with
Parse sql, then plan it using the given PlannerOptions.