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() -> SchemaInferrer
pub fn new() -> SchemaInferrer
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<SchemaInferrer, ZerError>
pub fn with_name_heuristics_file( self, path: impl AsRef<Path>, ) -> Result<SchemaInferrer, 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<SchemaInferrer, ZerError>
pub fn with_value_patterns_file( self, path: impl AsRef<Path>, ) -> Result<SchemaInferrer, 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,
) -> SchemaInferrer
pub fn override_field( self, name: impl Into<String>, kind: FieldKind, ) -> SchemaInferrer
Force a specific FieldKind for one field, bypassing inference.
This always takes precedence over both name-based and value-based heuristics.
Trait Implementations§
Source§impl Default for SchemaInferrer
impl Default for SchemaInferrer
Source§fn default() -> SchemaInferrer
fn default() -> SchemaInferrer
Auto Trait Implementations§
impl Freeze for SchemaInferrer
impl RefUnwindSafe for SchemaInferrer
impl Send for SchemaInferrer
impl Sync for SchemaInferrer
impl Unpin for SchemaInferrer
impl UnsafeUnpin for SchemaInferrer
impl UnwindSafe for SchemaInferrer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more