diff --git a/src/frontend/src/optimizer/plan_node/generic/scan.rs b/src/frontend/src/optimizer/plan_node/generic/scan.rs index 57323e01c5330..526a677e279b5 100644 --- a/src/frontend/src/optimizer/plan_node/generic/scan.rs +++ b/src/frontend/src/optimizer/plan_node/generic/scan.rs @@ -17,7 +17,6 @@ use std::rc::Rc; use educe::Educe; use fixedbitset::FixedBitSet; -use itertools::Itertools; use pretty_xmlish::Pretty; use risingwave_common::catalog::{ColumnDesc, Field, Schema, TableDesc}; use risingwave_common::util::column_index_mapping::ColIndexMapping; diff --git a/src/frontend/src/optimizer/plan_node/logical_scan.rs b/src/frontend/src/optimizer/plan_node/logical_scan.rs index 2f05cdc753182..e671f7412c661 100644 --- a/src/frontend/src/optimizer/plan_node/logical_scan.rs +++ b/src/frontend/src/optimizer/plan_node/logical_scan.rs @@ -232,17 +232,18 @@ impl LogicalScan { return (self.core.clone(), Condition::true_cond(), None); } - let mut mapping = ColIndexMapping::with_target_size( - self.required_col_idx().iter().map(|i| Some(*i)).collect(), - self.table_desc().columns.len(), - ); - // Since `required_col_idx` mapping is not invertible, we need to inverse manually. - let mut inverse_map = vec![None; mapping.target_size()]; - for (src, dst) in mapping.mapping_pairs() { - inverse_map[dst] = Some(src); - } - let mut inverse_mapping = - ColIndexMapping::with_target_size(inverse_map, mapping.source_size()); + let mut inverse_mapping = { + let mapping = ColIndexMapping::with_target_size( + self.required_col_idx().iter().map(|i| Some(*i)).collect(), + self.table_desc().columns.len(), + ); + // Since `required_col_idx` mapping is not invertible, we need to inverse manually. + let mut inverse_map = vec![None; mapping.target_size()]; + for (src, dst) in mapping.mapping_pairs() { + inverse_map[dst] = Some(src); + } + ColIndexMapping::with_target_size(inverse_map, mapping.source_size()) + }; predicate = predicate.rewrite_expr(&mut inverse_mapping);