Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: jayzhan211 <[email protected]>
  • Loading branch information
jayzhan211 committed May 13, 2024
1 parent 643ffe9 commit 9917b37
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 431 deletions.
6 changes: 0 additions & 6 deletions datafusion/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ macro_rules! downcast_value {
($Value: expr, $Type: ident) => {{
use std::any::type_name;
$Value.as_any().downcast_ref::<$Type>().ok_or_else(|| {
// panic!(
// "could not downcast value 1",
// );
DataFusionError::Internal(format!(
"could not cast value to {}",
type_name::<$Type>()
Expand All @@ -93,9 +90,6 @@ macro_rules! downcast_value {
($Value: expr, $Type: ident, $T: tt) => {{
use std::any::type_name;
$Value.as_any().downcast_ref::<$Type<$T>>().ok_or_else(|| {
// panic!(
// "could not downcast value 2",
// );
DataFusionError::Internal(format!(
"could not cast value to {}",
type_name::<$Type<$T>>()
Expand Down
51 changes: 0 additions & 51 deletions datafusion/core/src/physical_optimizer/aggregate_statistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ impl PhysicalOptimizerRule for AggregateStatistics {
take_optimizable_column_and_lit_count(&**expr, &stats)
{
projections.push((expressions::lit(non_null_rows), name.to_owned()));
// } else if let Some((num_rows, name)) =
// take_optimizable_table_count(&**expr, &stats)
// {
// projections.push((expressions::lit(num_rows), name.to_owned()));
} else if let Some((min, name)) = take_optimizable_min(&**expr, &stats) {
projections.push((expressions::lit(min), name.to_owned()));
} else if let Some((max, name)) = take_optimizable_max(&**expr, &stats) {
Expand Down Expand Up @@ -139,33 +135,6 @@ fn take_optimizable(node: &dyn ExecutionPlan) -> Option<Arc<dyn ExecutionPlan>>
None
}

/// If this agg_expr is a count that is exactly defined in the statistics, return it.
// fn take_optimizable_table_count(
// agg_expr: &dyn AggregateExpr,
// stats: &Statistics,
// ) -> Option<(ScalarValue, String)> {
// if let (&Precision::Exact(num_rows), Some(casted_expr)) = (
// &stats.num_rows,
// agg_expr.as_any().downcast_ref::<expressions::Count>(),
// ) {
// // TODO implementing Eq on PhysicalExpr would help a lot here
// if casted_expr.expressions().len() == 1 {
// if let Some(lit_expr) = casted_expr.expressions()[0]
// .as_any()
// .downcast_ref::<expressions::Literal>()
// {
// if lit_expr.value() == &COUNT_STAR_EXPANSION {
// return Some((
// ScalarValue::Int64(Some(num_rows as i64)),
// casted_expr.name().to_owned(),
// ));
// }
// }
// }
// }
// None
// }

/// If this agg_expr is a count that can be exactly derived from the statistics, return it.
fn take_optimizable_column_and_lit_count(
agg_expr: &dyn AggregateExpr,
Expand Down Expand Up @@ -203,26 +172,6 @@ fn take_optimizable_column_and_lit_count(
}
}

// if let (&Precision::Exact(num_rows), Some(casted_expr)) = (
// &stats.num_rows,
// agg_expr.as_any().downcast_ref::<expressions::Count>(),
// ) {
// if casted_expr.expressions().len() == 1 {
// // TODO optimize with exprs other than Column
// if let Some(col_expr) = casted_expr.expressions()[0]
// .as_any()
// .downcast_ref::<expressions::Column>()
// {
// let current_val = &col_stats[col_expr.index()].null_count;
// if let &Precision::Exact(val) = current_val {
// return Some((
// ScalarValue::Int64(Some((num_rows - val) as i64)),
// casted_expr.name().to_string(),
// ));
// }
// }
// }
// }
None
}

Expand Down
12 changes: 1 addition & 11 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1868,17 +1868,7 @@ fn write_name<W: Write>(w: &mut W, e: &Expr) -> Result<()> {
order_by,
null_treatment,
}) => {
match func_def {
AggregateFunctionDefinition::BuiltIn(..) => {
write_function_name(w, func_def.name(), *distinct, args)?;
}
AggregateFunctionDefinition::UDF(fun) => {
write_function_name(w, fun.name(), *distinct, args)?;
// write!(w, "{}(", fun.name())?;
// write_names_join(w, args, ",")?;
// write!(w, ")")?;
}
};
write_function_name(w, func_def.name(), *distinct, args)?;
if let Some(fe) = filter {
write!(w, " FILTER (WHERE {fe})")?;
};
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub trait AggregateUDFImpl: Debug + Send + Sync {
fn aliases(&self) -> &[String] {
&[]
}

/// Optionally apply per-UDaF simplification / rewrite rules.
///
/// This can be used to apply function specific simplification rules during
Expand Down
Loading

0 comments on commit 9917b37

Please sign in to comment.