pub struct TypeInference;
Expand description
Type inference utilities
Implementations§
Source§impl TypeInference
impl TypeInference
Sourcepub fn infer_from_string(value: &str) -> InferredType
pub fn infer_from_string(value: &str) -> InferredType
Infer the type of a single string value
This is the main entry point for type detection. Order of checks is important for performance and accuracy.
Sourcepub fn looks_like_datetime(value: &str) -> bool
pub fn looks_like_datetime(value: &str) -> bool
Check if a string looks like a datetime value
Uses strict regex patterns to avoid false positives with ID strings like “BQ-123456” or “ORDER-2024-001”
Sourcepub fn merge_types(type1: InferredType, type2: InferredType) -> InferredType
pub fn merge_types(type1: InferredType, type2: InferredType) -> InferredType
Merge two types when a column has mixed types
Rules:
- Same type -> keep it
- Null with anything -> the other type
- Integer + Float -> Float
- Any numeric + String -> String
- DateTime + String -> String
- Everything else -> String
Sourcepub fn infer_from_samples<'a, I>(values: I) -> InferredType
pub fn infer_from_samples<'a, I>(values: I) -> InferredType
Infer type from multiple sample values
Useful for determining column type from a sample of rows. Returns the most specific type that fits all non-null values.
Sourcepub fn can_coerce_to(value: &str, target_type: InferredType) -> bool
pub fn can_coerce_to(value: &str, target_type: InferredType) -> bool
Check if a value can be coerced to a specific type
Auto Trait Implementations§
impl Freeze for TypeInference
impl RefUnwindSafe for TypeInference
impl Send for TypeInference
impl Sync for TypeInference
impl Unpin for TypeInference
impl UnwindSafe for TypeInference
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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