Skip to content

Apache DataFusion SQL Query Engine

remove `unalias()` TableScan filters when create Physical Filter (#8404)

jakevin26196e648ecf
diff --git a/datafusion-cli/src/exec.rs b/datafusion-cli/src/exec.rs
index 1869e15ef5..63862caab8 100644
--- a/datafusion-cli/src/exec.rs
+++ b/datafusion-cli/src/exec.rs
@@ -221,14 +221,11 @@ async fn exec_and_print(
| LogicalPlan::Analyze(_)
);
- let df = match &plan {
- LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) => {
- create_external_table(ctx, cmd).await?;
- ctx.execute_logical_plan(plan).await?
- }
- _ => ctx.execute_logical_plan(plan).await?,
- };
+ if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &plan {
+ create_external_table(ctx, cmd).await?;
+ }
+ let df = ctx.execute_logical_plan(plan).await?;
let results = df.collect().await?;
let print_options = if should_ignore_maxrows {
diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs
index 9e64eb9c51..0e96b126b9 100644
--- a/datafusion/core/src/physical_planner.rs
+++ b/datafusion/core/src/physical_planner.rs
@@ -86,7 +86,7 @@ use datafusion_expr::expr::{
Cast, GetFieldAccess, GetIndexedField, GroupingSet, InList, Like, TryCast,
WindowFunction,
};
-use datafusion_expr::expr_rewriter::{unalias, unnormalize_cols};
+use datafusion_expr::expr_rewriter::unnormalize_cols;
use datafusion_expr::logical_plan::builder::wrap_projection_for_join_if_necessary;
use datafusion_expr::{
DescribeTable, DmlStatement, ScalarFunctionDefinition, StringifiedPlan, WindowFrame,
@@ -562,8 +562,7 @@ impl DefaultPhysicalPlanner {
// doesn't know (nor should care) how the relation was
// referred to in the query
let filters = unnormalize_cols(filters.iter().cloned());
- let unaliased: Vec<Expr> = filters.into_iter().map(unalias).collect();
- source.scan(session_state, projection.as_ref(), &unaliased, *fetch).await
+ source.scan(session_state, projection.as_ref(), &filters, *fetch).await
}
LogicalPlan::Copy(CopyTo{
input,
diff --git a/datafusion/physical-expr/src/array_expressions.rs b/datafusion/physical-expr/src/array_expressions.rs
index 0601c22ecf..9489a51fa3 100644
--- a/datafusion/physical-expr/src/array_expressions.rs
+++ b/datafusion/physical-expr/src/array_expressions.rs
@@ -595,14 +595,14 @@ fn general_array_pop(
) -> Result<(Vec<i64>, Vec<i64>)> {
if from_back {
let key = vec![0; list_array.len()];
- // Atttetion: `arr.len() - 1` in extra key defines the last element position (position = index + 1, not inclusive) we want in the new array.
+ // Attention: `arr.len() - 1` in extra key defines the last element position (position = index + 1, not inclusive) we want in the new array.
let extra_key: Vec<_> = list_array
.iter()
.map(|x| x.map_or(0, |arr| arr.len() as i64 - 1))
.collect();
Ok((key, extra_key))
} else {
- // Atttetion: 2 in the `key`` defines the first element position (position = index + 1) we want in the new array.
+ // Attention: 2 in the `key`` defines the first element position (position = index + 1) we want in the new array.
// We only handle two cases of the first element index: if the old array has any elements, starts from 2 (index + 1), or starts from initial.
let key: Vec<_> = list_array.iter().map(|x| x.map_or(0, |_| 2)).collect();
let extra_key: Vec<_> = list_array
@@ -1414,7 +1414,7 @@ pub fn array_replace_n(args: &[ArrayRef]) -> Result<ArrayRef> {
}
pub fn array_replace_all(args: &[ArrayRef]) -> Result<ArrayRef> {
- // replace all occurences (up to "i64::MAX")
+ // replace all occurrences (up to "i64::MAX")
let arr_n = vec![i64::MAX; args[0].len()];
general_replace(as_list_array(&args[0])?, &args[1], &args[2], arr_n)
}