mohitgurav20 commented on issue #25926: URL: https://github.com/apache/datafusion/issues/25926#issuecomment-5929673914
Hey @Toby1009, this is a great catch! The redundant sorts definitely add unnecessary overhead here. I was looking into the first gap you mentioned regarding ScalarSubqueryExpr::get_properties. You're exactly right — when a scalar subquery is cast (e.g., Int32 to Int64), the Singleton property is dropped because cast_expr_properties falls back to returning an unknown order when it encounters an unknown source type (like the Null range returned by the subquery). A straightforward fix for this part would be to update cast_expr_properties in datafusion/physical-expr/src/expressions/cast.rs so that if the child.sort_properties is already SortProperties::Singleton, we simply preserve it. Since casting a single constant value will always yield at most one value, it should remain a Singleton regardless of the source type. I'd be happy to pick this issue up and put up a PR to fix both gaps if you aren't already working on it. Could you confirm if that approach makes sense to you for the first gap? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
