Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions datafusion/physical-expr/src/expressions/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ use std::fmt::{Display, Formatter};
use std::ops::{Add, Sub};
use std::sync::Arc;

/// Perform DATE +/ INTERVAL math
/// Perform DATE/TIME/TIMESTAMP +/ INTERVAL math
#[derive(Debug)]
pub struct DateIntervalExpr {
pub struct DateTimeIntervalExpr {
lhs: Arc<dyn PhysicalExpr>,
op: Operator,
rhs: Arc<dyn PhysicalExpr>,
}

impl DateIntervalExpr {
impl DateTimeIntervalExpr {
/// Create a new instance of DateIntervalExpr
pub fn try_new(
lhs: Arc<dyn PhysicalExpr>,
Expand Down Expand Up @@ -76,13 +76,13 @@ impl DateIntervalExpr {
}
}

impl Display for DateIntervalExpr {
impl Display for DateTimeIntervalExpr {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{} {} {}", self.lhs, self.op, self.rhs)
}
}

impl PhysicalExpr for DateIntervalExpr {
impl PhysicalExpr for DateTimeIntervalExpr {
fn as_any(&self) -> &dyn Any {
self
}
Expand Down Expand Up @@ -652,7 +652,7 @@ mod tests {
let lhs = create_physical_expr(&dt, &dfs, &schema, &props)?;
let rhs = create_physical_expr(&interval, &dfs, &schema, &props)?;

let cut = DateIntervalExpr::try_new(lhs, op, rhs, &schema)?;
let cut = DateTimeIntervalExpr::try_new(lhs, op, rhs, &schema)?;
let res = cut.evaluate(&batch)?;

let mut builder = Date32Builder::new(8);
Expand Down Expand Up @@ -727,7 +727,7 @@ mod tests {
let lhs = create_physical_expr(dt, &dfs, &schema, &props)?;
let rhs = create_physical_expr(interval, &dfs, &schema, &props)?;

let cut = DateIntervalExpr::try_new(lhs, op, rhs, &schema)?;
let cut = DateTimeIntervalExpr::try_new(lhs, op, rhs, &schema)?;
let res = cut.evaluate(&batch)?;
Ok(res)
}
Expand Down
2 changes: 1 addition & 1 deletion datafusion/physical-expr/src/expressions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub use cast::{
cast, cast_column, cast_with_options, CastExpr, DEFAULT_DATAFUSION_CAST_OPTIONS,
};
pub use column::{col, Column};
pub use datetime::DateIntervalExpr;
pub use datetime::DateTimeIntervalExpr;
pub use get_indexed_field::GetIndexedFieldExpr;
pub use in_list::{in_list, InListExpr};
pub use is_not_null::{is_not_null, IsNotNullExpr};
Expand Down
6 changes: 4 additions & 2 deletions datafusion/physical-expr/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
use crate::expressions::try_cast;
use crate::{
execution_props::ExecutionProps,
expressions::{self, binary, Column, DateIntervalExpr, GetIndexedFieldExpr, Literal},
expressions::{
self, binary, Column, DateTimeIntervalExpr, GetIndexedFieldExpr, Literal,
},
functions, udf,
var_provider::VarType,
PhysicalExpr,
Expand Down Expand Up @@ -93,7 +95,7 @@ pub fn create_physical_expr(
DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _),
Operator::Plus | Operator::Minus,
DataType::Interval(_),
) => Ok(Arc::new(DateIntervalExpr::try_new(
) => Ok(Arc::new(DateTimeIntervalExpr::try_new(
lhs,
*op,
rhs,
Expand Down