notfilippo commented on PR #12853: URL: https://github.com/apache/datafusion/pull/12853#issuecomment-2437275323
> since we don't know what is the backing native type of it Isn't this the goal on having `native()` on [every LogicalType](https://github.com/notfilippo/datafusion/blob/7ed789176369c30972a41c76aaa32e3635a13222/datafusion/common/src/types/logical.rs#L78) (even user defined ones)? Anyway we could define a default mapping for NativeTypes and let user defined types override that behaviour via the trait. Something like: ```rust pub trait LogicalType: Sync + Send { fn native(&self) -> &NativeType; fn signature(&self) -> TypeSignature<'_>; fn default_cast(&self) -> &[DataType] { self.native().default_cast() } } ``` and then: ```rust impl LogicalType for NativeType { fn native(&self) -> &NativeType { self } fn signature(&self) -> TypeSignature<'_> { TypeSignature::Native(self) } fn default_cast(&self) -> &[DataType] { use NativeType::*; match self { Utf8 => &[DataType::Utf8View, DataType::LargeUtf8, DataType::Utf8], _ => todo!() } } } ``` > The order is Utf8View -> LargeUtf8 -> Utf8. So this means that if you received an Int64 then you first try to coerce to Utf8View and in what cases would you fall back to the LargeUtf8 and Utf8? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org