Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Dandandan committed Dec 7, 2023
1 parent e7daf66 commit 81dc5ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
3 changes: 0 additions & 3 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3134,9 +3134,6 @@ digraph {
.is_nullable());
}




#[test]
fn test_filter_is_scalar() {
// test empty placeholder
Expand Down
27 changes: 11 additions & 16 deletions datafusion/optimizer/src/optimize_projections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ fn optimize_projections(
add_projection_on_top_if_helpful(aggregate_input, necessary_exprs, true)?;

// Aggregate always needs at least one aggregate expr
if new_aggr_expr.len() == 0 && new_group_bys.len() == 0 && aggregate.aggr_expr.len() > 0 {
if new_aggr_expr.len() == 0
&& new_group_bys.len() == 0
&& aggregate.aggr_expr.len() > 0
{
new_aggr_expr = vec![aggregate.aggr_expr[0].clone()];
}

Expand Down Expand Up @@ -862,11 +865,11 @@ fn rewrite_projection_given_requirements(
#[cfg(test)]
mod tests {
use crate::optimize_projections::OptimizeProjections;
use arrow::datatypes::{Schema, Field, DataType};
use arrow::datatypes::{DataType, Field, Schema};
use datafusion_common::{Result, TableReference};
use datafusion_expr::{
binary_expr, col, lit, logical_plan::builder::LogicalPlanBuilder, LogicalPlan,
Operator, count, Expr, table_scan,
binary_expr, col, count, lit, logical_plan::builder::LogicalPlanBuilder,
table_scan, Expr, LogicalPlan, Operator,
};
use std::sync::Arc;

Expand Down Expand Up @@ -917,23 +920,15 @@ mod tests {
}
#[test]
fn test_nested_count() -> Result<()> {
let schema = Schema::new(vec![
Field::new("foo", DataType::Int32, false),
]);
let schema = Schema::new(vec![Field::new("foo", DataType::Int32, false)]);

let groups : Vec<Expr> = vec![];
let groups: Vec<Expr> = vec![];

let plan = table_scan(TableReference::none(), &schema, None)
.unwrap()
.aggregate(
groups.clone(),
vec![count(lit(1))],
)
.aggregate(groups.clone(), vec![count(lit(1))])
.unwrap()
.aggregate(
groups,
vec![count(lit(1))],
)
.aggregate(groups, vec![count(lit(1))])
.unwrap()
.build()
.unwrap();
Expand Down

0 comments on commit 81dc5ef

Please sign in to comment.