Skip to content

Commit f2b97c5

Browse files
alambccciudatu
authored andcommitted
Avoid some copies, encapsulate the handling of child indicies in OptimizeProjection (apache#10216)
1 parent 2fc5bde commit f2b97c5

File tree

3 files changed

+311
-237
lines changed

3 files changed

+311
-237
lines changed

datafusion/common/src/dfschema.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,22 @@ impl DFSchema {
347347
matches.next()
348348
}
349349

350-
/// Find the index of the column with the given qualifier and name
351-
pub fn index_of_column(&self, col: &Column) -> Result<usize> {
350+
/// Find the index of the column with the given qualifier and name,
351+
/// returning `None` if not found
352+
///
353+
/// See [Self::index_of_column] for a version that returns an error if the
354+
/// column is not found
355+
pub fn maybe_index_of_column(&self, col: &Column) -> Option<usize> {
352356
self.index_of_column_by_name(col.relation.as_ref(), &col.name)
357+
}
358+
359+
/// Find the index of the column with the given qualifier and name,
360+
/// returning `Err` if not found
361+
///
362+
/// See [Self::maybe_index_of_column] for a version that returns `None` if
363+
/// the column is not found
364+
pub fn index_of_column(&self, col: &Column) -> Result<usize> {
365+
self.maybe_index_of_column(col)
353366
.ok_or_else(|| field_not_found(col.relation.clone(), &col.name, self))
354367
}
355368

0 commit comments

Comments
 (0)