Skip to content

Commit

Permalink
Rename DateIntervalExpr to DateTimeIntervalExpr (#3150)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Aug 15, 2022
1 parent d9dab92 commit fb70057
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions datafusion/physical-expr/src/expressions/datetime.rs
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
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
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

0 comments on commit fb70057

Please sign in to comment.