pub trait LogicalTypeProvider: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn arrow_type(&self) -> DataType;
fn from_literal(&self, s: &str) -> Result<ScalarValue, FnError>;
fn to_display(&self, v: &ScalarValue) -> Result<String, FnError>;
fn cast_to(
&self,
v: &ColumnarValue,
target: &DataType,
) -> Result<ColumnarValue, FnError>;
fn cast_from(&self, v: &ColumnarValue) -> Result<ColumnarValue, FnError>;
// Provided methods
fn encoding_version(&self) -> &str { ... }
fn compat_check(&self, old: &dyn LogicalTypeProvider) -> Result<(), FnError> { ... }
}Expand description
A logical type plugin (Arrow extension type).
Required Methods§
Sourcefn arrow_type(&self) -> DataType
fn arrow_type(&self) -> DataType
Physical Arrow storage type backing this logical type.
Sourcefn from_literal(&self, s: &str) -> Result<ScalarValue, FnError>
fn from_literal(&self, s: &str) -> Result<ScalarValue, FnError>
Sourcefn to_display(&self, v: &ScalarValue) -> Result<String, FnError>
fn to_display(&self, v: &ScalarValue) -> Result<String, FnError>
Sourcefn cast_to(
&self,
v: &ColumnarValue,
target: &DataType,
) -> Result<ColumnarValue, FnError>
fn cast_to( &self, v: &ColumnarValue, target: &DataType, ) -> Result<ColumnarValue, FnError>
Sourcefn cast_from(&self, v: &ColumnarValue) -> Result<ColumnarValue, FnError>
fn cast_from(&self, v: &ColumnarValue) -> Result<ColumnarValue, FnError>
Provided Methods§
Sourcefn encoding_version(&self) -> &str
fn encoding_version(&self) -> &str
Optional opaque version stamp for the on-disk encoding.
Default is "1". Override when bumping an encoding-breaking
change so Self::compat_check can reject a reload that would
silently mis-decode already-persisted data.
Sourcefn compat_check(&self, old: &dyn LogicalTypeProvider) -> Result<(), FnError>
fn compat_check(&self, old: &dyn LogicalTypeProvider) -> Result<(), FnError>
Reject a reload that would change the Arrow extension contract.
Default implementation enforces the §11.2.1 invariant: the new
provider must keep the same extension name() and the same
physical arrow_type() and the same Self::encoding_version
as the old provider. Any mismatch is a hard reload error
because previously-stored values would otherwise become
unreadable.
§Errors
Returns FnError (code FnError::CODE_TYPE_COERCION) when
the new provider’s contract differs from the old.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".