Skip to content

Commit

Permalink
add accessor methods to DateTimeIntervalExpr (#3440)
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove authored Sep 11, 2022
1 parent 5af707b commit 1ec67da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions datafusion/physical-expr/src/expressions/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ impl DateTimeIntervalExpr {
))),
}
}

/// Get the left-hand side expression
pub fn lhs(&self) -> &Arc<dyn PhysicalExpr> {
&self.lhs
}

/// Get the operator
pub fn op(&self) -> &Operator {
&self.op
}

/// Get the right-hand side expression
pub fn rhs(&self) -> &Arc<dyn PhysicalExpr> {
&self.rhs
}
}

impl Display for DateTimeIntervalExpr {
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 1ec67da

Please sign in to comment.