From 1ec67da508ce4080764f8d9da589e0be9f145f12 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sat, 10 Sep 2022 23:46:02 -0600 Subject: [PATCH] add accessor methods to DateTimeIntervalExpr (#3440) --- .../physical-expr/src/expressions/datetime.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/datafusion/physical-expr/src/expressions/datetime.rs b/datafusion/physical-expr/src/expressions/datetime.rs index 9f2beae0019d..fa021f61a940 100644 --- a/datafusion/physical-expr/src/expressions/datetime.rs +++ b/datafusion/physical-expr/src/expressions/datetime.rs @@ -74,6 +74,21 @@ impl DateTimeIntervalExpr { ))), } } + + /// Get the left-hand side expression + pub fn lhs(&self) -> &Arc { + &self.lhs + } + + /// Get the operator + pub fn op(&self) -> &Operator { + &self.op + } + + /// Get the right-hand side expression + pub fn rhs(&self) -> &Arc { + &self.rhs + } } impl Display for DateTimeIntervalExpr { @@ -727,7 +742,15 @@ mod tests { let lhs = create_physical_expr(dt, &dfs, &schema, &props)?; let rhs = create_physical_expr(interval, &dfs, &schema, &props)?; + let lhs_str = format!("{}", lhs); + let rhs_str = format!("{}", rhs); + let cut = DateTimeIntervalExpr::try_new(lhs, op, rhs, &schema)?; + + assert_eq!(lhs_str, format!("{}", cut.lhs())); + assert_eq!(op, cut.op().clone()); + assert_eq!(rhs_str, format!("{}", cut.rhs())); + let res = cut.evaluate(&batch)?; Ok(res) }