wiedld commented on code in PR #14329: URL: https://github.com/apache/datafusion/pull/14329#discussion_r1931104682
########## 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: This is a user-defined invariant. -- 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