shehabgamin commented on issue #14296: URL: https://github.com/apache/datafusion/issues/14296#issuecomment-2614200125
I like the idea of "user-defined coercion rules" and think we should take it a step further by striving for a paradigm of "user-defined configurability" in DataFusion. Just as SQLParser has `GenericDialect`, which is permissive and general-purpose, applying a similar principle to components of DataFusion would provide greater flexibility and adaptability. Attaching `with_type_coercion_rules` to a `SessionContext` is an interesting idea, but I worry this approach might not be flexible enough for nuanced situations. Functions, expressions, and other components often have unique coercion rules specific to their context or intended use cases. A one-size-fits-all approach at the `SessionContext` level might not address these needs, so a more granular mechanism to define and override coercion rules at a localized scope could be necessary. For instance, with the built-in UDFs that DataFusion offers, it would be powerful if users could customize various components of a UDF. Take the `AsciiFunc` as an example, both of the following signatures could be valid depending on user requirements: ``` Signature::string(1, Volatility::Immutable) Signature::coercible( vec![TypeSignatureClass::Native(logical_string())], Volatility::Immutable, ) ``` The default implementation of `AsciiFunc` would prioritize being permissive and general-purpose: ``` impl AsciiFunc { pub fn new() -> Self { Self { signature: Signature::one_of( vec![ TypeSignature::Coercible(vec![TypeSignatureClass::Native( logical_string(), )]), ], Volatility::Immutable, ), } } } ``` However, what if users could further customize the behavior of `AsciiFunc` like this? ``` let ascii = AsciiFunc::new() .with_signature(Signature::string(1, Volatility::Immutable)) // Define other customizations as well .with_display_name(vec![lit("Meow")]) .with_is_nullable(false) ... .with_... ... ?; ``` -- 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