Skip to content

Commit 26196e6

Browse files
authored
remove unalias() TableScan filters when create Physical Filter (#8404)
- remove `unalias` TableScan filters - refactor CreateExternalTable - fix typo
1 parent f6af014 commit 26196e6

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

datafusion-cli/src/exec.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,11 @@ async fn exec_and_print(
221221
| LogicalPlan::Analyze(_)
222222
);
223223

224-
let df = match &plan {
225-
LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) => {
226-
create_external_table(ctx, cmd).await?;
227-
ctx.execute_logical_plan(plan).await?
228-
}
229-
_ => ctx.execute_logical_plan(plan).await?,
230-
};
224+
if let LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) = &plan {
225+
create_external_table(ctx, cmd).await?;
226+
}
231227

228+
let df = ctx.execute_logical_plan(plan).await?;
232229
let results = df.collect().await?;
233230

234231
let print_options = if should_ignore_maxrows {

datafusion/core/src/physical_planner.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ use datafusion_expr::expr::{
8686
Cast, GetFieldAccess, GetIndexedField, GroupingSet, InList, Like, TryCast,
8787
WindowFunction,
8888
};
89-
use datafusion_expr::expr_rewriter::{unalias, unnormalize_cols};
89+
use datafusion_expr::expr_rewriter::unnormalize_cols;
9090
use datafusion_expr::logical_plan::builder::wrap_projection_for_join_if_necessary;
9191
use datafusion_expr::{
9292
DescribeTable, DmlStatement, ScalarFunctionDefinition, StringifiedPlan, WindowFrame,
@@ -562,8 +562,7 @@ impl DefaultPhysicalPlanner {
562562
// doesn't know (nor should care) how the relation was
563563
// referred to in the query
564564
let filters = unnormalize_cols(filters.iter().cloned());
565-
let unaliased: Vec<Expr> = filters.into_iter().map(unalias).collect();
566-
source.scan(session_state, projection.as_ref(), &unaliased, *fetch).await
565+
source.scan(session_state, projection.as_ref(), &filters, *fetch).await
567566
}
568567
LogicalPlan::Copy(CopyTo{
569568
input,

datafusion/physical-expr/src/array_expressions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,14 +595,14 @@ fn general_array_pop(
595595
) -> Result<(Vec<i64>, Vec<i64>)> {
596596
if from_back {
597597
let key = vec![0; list_array.len()];
598-
// Atttetion: `arr.len() - 1` in extra key defines the last element position (position = index + 1, not inclusive) we want in the new array.
598+
// Attention: `arr.len() - 1` in extra key defines the last element position (position = index + 1, not inclusive) we want in the new array.
599599
let extra_key: Vec<_> = list_array
600600
.iter()
601601
.map(|x| x.map_or(0, |arr| arr.len() as i64 - 1))
602602
.collect();
603603
Ok((key, extra_key))
604604
} else {
605-
// Atttetion: 2 in the `key`` defines the first element position (position = index + 1) we want in the new array.
605+
// Attention: 2 in the `key`` defines the first element position (position = index + 1) we want in the new array.
606606
// 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.
607607
let key: Vec<_> = list_array.iter().map(|x| x.map_or(0, |_| 2)).collect();
608608
let extra_key: Vec<_> = list_array
@@ -1414,7 +1414,7 @@ pub fn array_replace_n(args: &[ArrayRef]) -> Result<ArrayRef> {
14141414
}
14151415

14161416
pub fn array_replace_all(args: &[ArrayRef]) -> Result<ArrayRef> {
1417-
// replace all occurences (up to "i64::MAX")
1417+
// replace all occurrences (up to "i64::MAX")
14181418
let arr_n = vec![i64::MAX; args[0].len()];
14191419
general_replace(as_list_array(&args[0])?, &args[1], &args[2], arr_n)
14201420
}

0 commit comments

Comments
 (0)