wiedld commented on code in PR #14329: URL: https://github.com/apache/datafusion/pull/14329#discussion_r1931137282
########## datafusion/expr/src/logical_plan/invariants.rs: ########## @@ -28,6 +30,24 @@ use crate::{ Aggregate, Expr, Filter, Join, JoinType, LogicalPlan, Window, }; +use super::Extension; + +pub type InvariantFn = Arc<dyn Fn(&LogicalPlan) -> Result<()> + Send + Sync>; + +#[derive(Clone)] +pub struct Invariant { + pub kind: InvariantLevel, + pub fun: InvariantFn, +} + +impl Invariant { + /// Return an error if invariant does not hold true. + pub fn check(&self, plan: &LogicalPlan) -> Result<()> { + (self.fun)(plan) + } +} Review Comment: Note: a followup PR will enable a user-defined LP invariant to be run against all LP nodes (not just extension nodes). That would handle [this use case](https://github.com/apache/datafusion/issues/14029#issuecomment-2606608468) requested on the issue. -- 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