Skip to content

Commit

Permalink
Change suffix on some expressions from Exec to Expr (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove authored Jul 16, 2024
1 parent 6f9b56a commit 8e1c7e1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
24 changes: 12 additions & 12 deletions native/core/src/execution/datafusion/expressions/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,30 +146,30 @@ make_predicate_function!(Contains, contains_dyn, contains_utf8_scalar_dyn);
// make_predicate_function!(RLike, rlike_dyn, rlike_utf8_scalar_dyn);

#[derive(Debug, Hash)]
pub struct SubstringExec {
pub struct SubstringExpr {
pub child: Arc<dyn PhysicalExpr>,
pub start: i64,
pub len: u64,
}

#[derive(Debug, Hash)]
pub struct StringSpaceExec {
pub struct StringSpaceExpr {
pub child: Arc<dyn PhysicalExpr>,
}

impl SubstringExec {
impl SubstringExpr {
pub fn new(child: Arc<dyn PhysicalExpr>, start: i64, len: u64) -> Self {
Self { child, start, len }
}
}

impl StringSpaceExec {
impl StringSpaceExpr {
pub fn new(child: Arc<dyn PhysicalExpr>) -> Self {
Self { child }
}
}

impl Display for SubstringExec {
impl Display for SubstringExpr {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
Expand All @@ -179,13 +179,13 @@ impl Display for SubstringExec {
}
}

impl Display for StringSpaceExec {
impl Display for StringSpaceExpr {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "StringSpace [child: {}] ", self.child)
}
}

impl PartialEq<dyn Any> for SubstringExec {
impl PartialEq<dyn Any> for SubstringExpr {
fn eq(&self, other: &dyn Any) -> bool {
down_cast_any_ref(other)
.downcast_ref::<Self>()
Expand All @@ -194,7 +194,7 @@ impl PartialEq<dyn Any> for SubstringExec {
}
}

impl PhysicalExpr for SubstringExec {
impl PhysicalExpr for SubstringExpr {
fn as_any(&self) -> &dyn Any {
self
}
Expand Down Expand Up @@ -229,7 +229,7 @@ impl PhysicalExpr for SubstringExec {
self: Arc<Self>,
children: Vec<Arc<dyn PhysicalExpr>>,
) -> datafusion_common::Result<Arc<dyn PhysicalExpr>> {
Ok(Arc::new(SubstringExec::new(
Ok(Arc::new(SubstringExpr::new(
children[0].clone(),
self.start,
self.len,
Expand All @@ -245,7 +245,7 @@ impl PhysicalExpr for SubstringExec {
}
}

impl PartialEq<dyn Any> for StringSpaceExec {
impl PartialEq<dyn Any> for StringSpaceExpr {
fn eq(&self, other: &dyn Any) -> bool {
down_cast_any_ref(other)
.downcast_ref::<Self>()
Expand All @@ -254,7 +254,7 @@ impl PartialEq<dyn Any> for StringSpaceExec {
}
}

impl PhysicalExpr for StringSpaceExec {
impl PhysicalExpr for StringSpaceExpr {
fn as_any(&self) -> &dyn Any {
self
}
Expand Down Expand Up @@ -294,7 +294,7 @@ impl PhysicalExpr for StringSpaceExec {
self: Arc<Self>,
children: Vec<Arc<dyn PhysicalExpr>>,
) -> datafusion_common::Result<Arc<dyn PhysicalExpr>> {
Ok(Arc::new(StringSpaceExec::new(children[0].clone())))
Ok(Arc::new(StringSpaceExpr::new(children[0].clone())))
}

fn dyn_hash(&self, state: &mut dyn Hasher) {
Expand Down
18 changes: 9 additions & 9 deletions native/core/src/execution/datafusion/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use crate::{
scalar_funcs::create_comet_physical_fun,
stats::StatsType,
stddev::Stddev,
strings::{Contains, EndsWith, Like, StartsWith, StringSpaceExec, SubstringExec},
strings::{Contains, EndsWith, Like, StartsWith, StringSpaceExpr, SubstringExpr},
subquery::Subquery,
sum_decimal::SumDecimal,
unbound::UnboundColumn,
Expand Down Expand Up @@ -108,7 +108,7 @@ use datafusion_comet_proto::{
spark_partitioning::{partitioning::PartitioningStruct, Partitioning as SparkPartitioning},
};
use datafusion_comet_spark_expr::{
Abs, Cast, DateTruncExec, HourExec, IfExpr, MinuteExec, SecondExec, TimestampTruncExec,
Abs, Cast, DateTruncExpr, HourExpr, IfExpr, MinuteExpr, SecondExpr, TimestampTruncExpr,
};

// For clippy error on type_complexity.
Expand Down Expand Up @@ -378,32 +378,32 @@ impl PhysicalPlanner {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;
let timezone = expr.timezone.clone();

Ok(Arc::new(HourExec::new(child, timezone)))
Ok(Arc::new(HourExpr::new(child, timezone)))
}
ExprStruct::Minute(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;
let timezone = expr.timezone.clone();

Ok(Arc::new(MinuteExec::new(child, timezone)))
Ok(Arc::new(MinuteExpr::new(child, timezone)))
}
ExprStruct::Second(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;
let timezone = expr.timezone.clone();

Ok(Arc::new(SecondExec::new(child, timezone)))
Ok(Arc::new(SecondExpr::new(child, timezone)))
}
ExprStruct::TruncDate(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema.clone())?;
let format = self.create_expr(expr.format.as_ref().unwrap(), input_schema)?;

Ok(Arc::new(DateTruncExec::new(child, format)))
Ok(Arc::new(DateTruncExpr::new(child, format)))
}
ExprStruct::TruncTimestamp(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema.clone())?;
let format = self.create_expr(expr.format.as_ref().unwrap(), input_schema)?;
let timezone = expr.timezone.clone();

Ok(Arc::new(TimestampTruncExec::new(child, format, timezone)))
Ok(Arc::new(TimestampTruncExpr::new(child, format, timezone)))
}
ExprStruct::Substring(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;
Expand All @@ -412,7 +412,7 @@ impl PhysicalPlanner {
// substring negative len is treated as 0 in Spark
let len = std::cmp::max(expr.len, 0);

Ok(Arc::new(SubstringExec::new(
Ok(Arc::new(SubstringExpr::new(
child,
start as i64,
len as u64,
Expand All @@ -421,7 +421,7 @@ impl PhysicalPlanner {
ExprStruct::StringSpace(expr) => {
let child = self.create_expr(expr.child.as_ref().unwrap(), input_schema)?;

Ok(Arc::new(StringSpaceExec::new(child)))
Ok(Arc::new(StringSpaceExpr::new(child)))
}
ExprStruct::Contains(expr) => {
let left = self.create_expr(expr.left.as_ref().unwrap(), input_schema.clone())?;
Expand Down
2 changes: 1 addition & 1 deletion native/spark-expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use abs::Abs;
pub use cast::Cast;
pub use error::{SparkError, SparkResult};
pub use if_expr::IfExpr;
pub use temporal::{DateTruncExec, HourExec, MinuteExec, SecondExec, TimestampTruncExec};
pub use temporal::{DateTruncExpr, HourExpr, MinuteExpr, SecondExpr, TimestampTruncExpr};

/// Spark supports three evaluation modes when evaluating expressions, which affect
/// the behavior when processing input values that are invalid or would result in an
Expand Down
Loading

0 comments on commit 8e1c7e1

Please sign in to comment.