Expand description
Schema management system for schema-aware analysis and optimization.
Provides a Schema trait and MappingSchema implementation analogous
to Python sqlglot’s MappingSchema. This is the foundation for type
annotation, column qualification, projection pushdown, and lineage analysis.
§Example
use sqlglot_rust::schema::{MappingSchema, Schema};
use sqlglot_rust::ast::DataType;
use sqlglot_rust::Dialect;
let mut schema = MappingSchema::new(Dialect::Ansi);
schema.add_table(
&["catalog", "db", "users"],
vec![
("id".to_string(), DataType::Int),
("name".to_string(), DataType::Varchar(Some(255))),
("email".to_string(), DataType::Text),
],
).unwrap();
assert_eq!(
schema.column_names(&["catalog", "db", "users"]).unwrap(),
vec!["id", "name", "email"],
);
assert_eq!(
schema.get_column_type(&["catalog", "db", "users"], "id").unwrap(),
DataType::Int,
);
assert!(schema.has_column(&["catalog", "db", "users"], "id"));Structs§
- Mapping
Schema - A schema backed by in-memory hash maps, supporting 3-level nesting:
catalog → database → table → column → type.
Enums§
- Schema
Error - Errors specific to schema operations.
Traits§
- Schema
- Schema trait for schema-aware analysis and optimization.
Functions§
- ensure_
schema - Build a
MappingSchemafrom a nested map structure. - ensure_
schema_ nested - Build a
MappingSchemafrom a 3-level nested map:catalog → database → table → column → type. - is_
case_ sensitive_ dialect - Returns
trueif the dialect treats unquoted identifiers as case-sensitive. - normalize_
identifier - Normalize an identifier according to the given dialect’s conventions.
Type Aliases§
- Catalog
Map - Type alias for the 3-level nested schema map:
catalog → database → table → column → type.