Expand description
Polyglot Core - SQL parsing and dialect translation library
This library provides the core functionality for parsing SQL statements, building an abstract syntax tree (AST), and generating SQL in different dialects.
§Architecture
The library follows a pipeline architecture:
- Tokenizer - Converts SQL string to token stream
- Parser - Builds AST from tokens
- Generator - Converts AST back to SQL string
Each stage can be customized per dialect.
Re-exports§
pub use dialects::Dialect;pub use dialects::DialectType;pub use error::Error;pub use error::Result;pub use error::ValidationError;pub use error::ValidationResult;pub use error::ValidationSeverity;pub use expressions::Expression;pub use generator::Generator;pub use helper::csv;pub use helper::find_new_name;pub use helper::is_date_unit;pub use helper::is_float;pub use helper::is_int;pub use helper::is_iso_date;pub use helper::is_iso_datetime;pub use helper::merge_ranges;pub use helper::name_sequence;pub use helper::seq_get;pub use helper::split_num_words;pub use helper::tsort;pub use helper::while_changing;pub use helper::DATE_UNITS;pub use parser::Parser;pub use resolver::is_column_ambiguous;pub use resolver::resolve_column;pub use resolver::Resolver;pub use resolver::ResolverError;pub use resolver::ResolverResult;pub use schema::ensure_schema;pub use schema::from_simple_map;pub use schema::normalize_name;pub use schema::MappingSchema;pub use schema::Schema;pub use schema::SchemaError;pub use scope::build_scope;pub use scope::find_all_in_scope;pub use scope::find_in_scope;pub use scope::traverse_scope;pub use scope::walk_in_scope;pub use scope::ColumnRef;pub use scope::Scope;pub use scope::ScopeType;pub use scope::SourceInfo;pub use time::format_time;pub use time::is_valid_timezone;pub use time::subsecond_precision;pub use time::TIMEZONES;pub use tokens::Token;pub use tokens::TokenType;pub use tokens::Tokenizer;pub use traversal::contains_aggregate;pub use traversal::contains_subquery;pub use traversal::contains_window_function;pub use traversal::find_ancestor;pub use traversal::find_parent;pub use traversal::get_columns;pub use traversal::get_tables;pub use traversal::is_aggregate;pub use traversal::is_column;pub use traversal::is_function;pub use traversal::is_literal;pub use traversal::is_select;pub use traversal::is_subquery;pub use traversal::is_window_function;pub use traversal::transform;pub use traversal::transform_map;pub use traversal::BfsIter;pub use traversal::DfsIter;pub use traversal::ExpressionWalk;pub use traversal::ParentInfo;pub use traversal::TreeContext;pub use trie::new_trie;pub use trie::new_trie_from_keys;pub use trie::Trie;pub use trie::TrieResult;pub use optimizer::annotate_types;pub use optimizer::annotate_types;pub use optimizer::TypeAnnotator;pub use optimizer::TypeCoercionClass;
Modules§
- builder
- Fluent SQL Builder API
- dialects
- SQL Dialect System
- diff
- AST Diff - Compare SQL expressions
- error
- Error types for polyglot-sql
- expressions
- SQL Expression AST (Abstract Syntax Tree).
- generator
- SQL Generator – converts an AST back into SQL strings.
- helper
- Helper utilities for SQL processing
- lineage
- Column Lineage Tracking
- optimizer
- SQL Optimizer Module
- parser
- SQL Parser – recursive-descent parser that converts a token stream into an AST.
- planner
- Query Execution Planner
- resolver
- Column Resolver Module
- schema
- Schema management for SQL queries
- scope
- Scope Analysis Module
- time
- Time format conversion utilities
- tokens
- Token types and tokenization for SQL parsing
- transforms
- SQL AST Transforms
- traversal
- Tree traversal utilities for SQL expression ASTs.
- trie
- Trie data structure for efficient prefix matching