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
7 changes: 3 additions & 4 deletions datafusion/optimizer/src/decorrelate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,9 @@ impl TreeNodeRewriter for PullUpCorrelatedExpr {
)?;
if !expr_result_map_for_count_bug.is_empty() {
// has count bug
let un_matched_row = Expr::Alias(Alias::new(
Expr::Literal(ScalarValue::Boolean(Some(true))),
UN_MATCHED_ROW_INDICATOR.to_string(),
));
let un_matched_row =
Expr::Literal(ScalarValue::Boolean(Some(true)))
.alias(UN_MATCHED_ROW_INDICATOR);
// add the unmatched rows indicator to the Aggregation's group expressions
missing_exprs.push(un_matched_row);
}
Expand Down
20 changes: 9 additions & 11 deletions datafusion/optimizer/src/single_distinct_to_groupby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{OptimizerConfig, OptimizerRule};
use datafusion_common::Result;
use datafusion_expr::{
col,
expr::{AggregateFunction, Alias},
expr::AggregateFunction,
logical_plan::{Aggregate, LogicalPlan},
Expr,
};
Expand Down Expand Up @@ -168,16 +168,14 @@ impl OptimizerRule for SingleDistinctToGroupBy {
args[0].clone().alias(SINGLE_DISTINCT_ALIAS),
);
}
Ok(Expr::Alias(Alias::new(
Expr::AggregateFunction(AggregateFunction::new(
fun.clone(),
vec![col(SINGLE_DISTINCT_ALIAS)],
false, // intentional to remove distinct here
filter.clone(),
order_by.clone(),
)),
aggr_expr.display_name()?,
)))
Ok(Expr::AggregateFunction(AggregateFunction::new(
fun.clone(),
vec![col(SINGLE_DISTINCT_ALIAS)],
false, // intentional to remove distinct here
filter.clone(),
order_by.clone(),
))
.alias(aggr_expr.display_name()?))
}
_ => Ok(aggr_expr.clone()),
})
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sql/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
&[&[plan.schema()]],
&plan.using_columns()?,
)?;
let expr = Expr::Alias(Alias::new(col, self.normalizer.normalize(alias)));
let expr = col.alias(self.normalizer.normalize(alias));
Ok(vec![expr])
}
SelectItem::Wildcard(options) => {
Expand Down