jayzhan211 commented on PR #14440: URL: https://github.com/apache/datafusion/pull/14440#issuecomment-2659202892
> > Enum looks good to me but "adding user defined coercion variant" is not clear to me since I think the Coercible signature is user-defined builtin, they can change the type they need and set it into their own function 🤔 > > That is true that `TypeSignature::Coercable` allows users to define whatever they want. > > I was thinking for @shehabgamin 's usecase where he wanted to implement coercsion that had a slightly different rules about when to cast Integer --> String. He could implement that with an entirely custom coercion, but it might be nice to just adjust the rules somehow (and reuse most of the rest of the logic ) 🤔 Modifying Signature::Coercible alone won't achieve what @shehabgamin wants because, regardless of the approach, they would still need to: Fork the entire function 1. Modify its signature 2. Register it in the function map 3. Even if we introduce another variant, we would still maintain a version for DataFusion, while others would have to go through the same process to customize it for their needs. A better solution would be to separate the function signature from the function itself, as shown below: ```rust pub struct ScalarFunctionExpr { fun: Arc<ScalarUDF>, name: String, args: Vec<Arc<dyn PhysicalExpr>>, return_type: DataType, nullable: bool, // new signature: TypeSignature } ``` This change fundamentally impacts how scalar functions are structured... -- 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