Expand description
§VibeSQL
A SQL parser and semantic analyzer library with standard SQL type system.
This library provides a complete SQL parsing and analysis pipeline that can be used as a middleware layer between transport and storage layers in database systems.
§Features
- Full SQL lexer/tokenizer
- Comprehensive AST representation
- Expression, query, and statement parsing
- Standard SQL type system (BIGINT, VARCHAR, DOUBLE PRECISION, etc.)
- Semantic analysis with type checking
- Extensible catalog with custom types, functions, and tables
- Zero dependencies (standard library only)
§Quick Start
use vibesql::{Parser, Analyzer};
let sql = "SELECT id, name FROM users WHERE age > 21";
let mut parser = Parser::new(sql);
let ast = parser.parse().expect("Failed to parse SQL");§Extensibility
Use CatalogBuilder to create catalogs with custom functions and types:
use vibesql::catalog::{CatalogBuilder, TypeRegistry};
use vibesql::types::SqlType;
let catalog = CatalogBuilder::new()
.with_builtins()
.add_scalar_function("MY_HASH", SqlType::Int64)
.add_table("users", |t| {
t.primary_key("id", SqlType::Int64)
.column("name", SqlType::Varchar)
.column("email", SqlType::Varchar)
})
.build();§Type System
VibeSQL uses standard SQL type names:
| Type | Display Name |
|---|---|
SqlType::Bool | BOOLEAN |
SqlType::Int32 | INTEGER |
SqlType::Int64 | BIGINT |
SqlType::Float32 | REAL |
SqlType::Float64 | DOUBLE PRECISION |
SqlType::Varchar | VARCHAR |
SqlType::Varbinary | VARBINARY |
Re-exports§
pub use analyzer::AnalyzedQuery;pub use analyzer::Analyzer;pub use analyzer::AnalyzerError;pub use analyzer::OutputColumn;pub use catalog::Catalog;pub use catalog::CatalogBuilder;pub use catalog::ColumnSchema;pub use catalog::FunctionSignature;pub use catalog::MemoryCatalog;pub use catalog::TableBuilder;pub use catalog::TableSchema;pub use catalog::TableSchemaBuilder;pub use catalog::TypeRegistry;pub use error::Error;pub use error::Result;pub use lexer::Lexer;pub use lexer::Token;pub use lexer::TokenKind;pub use parser::Parser;pub use types::SqlType;pub use types::Value;pub use ast::*;