pub struct SchemaInferrer { /* private fields */ }Expand description
Automatic schema detector.
Samples column names and record values to produce a best-effort Schema.
The inferred schema should be reviewed before use in production, call
individual field overrides for any column the heuristics might misclassify.
§Example
let schema = SchemaInferrer::new()
.override_field("internal_code", FieldKind::Id)
.override_field("notes", FieldKind::FreeText)
.infer(&records)
.unwrap();Implementations§
Source§impl SchemaInferrer
impl SchemaInferrer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new inferrer loading heuristics from the embedded defaults
(or from ZER_NAME_HEURISTICS / ZER_VALUE_PATTERNS env vars if set).
Sourcepub fn with_name_heuristics_file(
self,
path: impl AsRef<Path>,
) -> Result<Self, ZerError>
pub fn with_name_heuristics_file( self, path: impl AsRef<Path>, ) -> Result<Self, ZerError>
Override the name-based heuristics with rules loaded from a TOML file.
Returns Err if the file cannot be read or parsed.
Sourcepub fn with_value_patterns_file(
self,
path: impl AsRef<Path>,
) -> Result<Self, ZerError>
pub fn with_value_patterns_file( self, path: impl AsRef<Path>, ) -> Result<Self, ZerError>
Override the value-pattern sampling with patterns loaded from a TOML file.
Returns Err if the file cannot be read, parsed, or contains an invalid regex.
Sourcepub fn override_field(self, name: impl Into<String>, kind: FieldKind) -> Self
pub fn override_field(self, name: impl Into<String>, kind: FieldKind) -> Self
Force a specific FieldKind for one field, bypassing inference.
This always takes precedence over both name-based and value-based heuristics.