Skip to content

Commit

Permalink
Avoid some copies, encapsulate the handling of child indicies in `Opt…
Browse files Browse the repository at this point in the history
…imizeProjection` (#10216)
  • Loading branch information
alamb authored Apr 25, 2024
1 parent b87f210 commit 5c86db0
Show file tree
Hide file tree
Showing 3 changed files with 311 additions and 237 deletions.
17 changes: 15 additions & 2 deletions datafusion/common/src/dfschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,22 @@ impl DFSchema {
matches.next()
}

/// Find the index of the column with the given qualifier and name
pub fn index_of_column(&self, col: &Column) -> Result<usize> {
/// Find the index of the column with the given qualifier and name,
/// returning `None` if not found
///
/// See [Self::index_of_column] for a version that returns an error if the
/// column is not found
pub fn maybe_index_of_column(&self, col: &Column) -> Option<usize> {
self.index_of_column_by_name(col.relation.as_ref(), &col.name)
}

/// Find the index of the column with the given qualifier and name,
/// returning `Err` if not found
///
/// See [Self::maybe_index_of_column] for a version that returns `None` if
/// the column is not found
pub fn index_of_column(&self, col: &Column) -> Result<usize> {
self.maybe_index_of_column(col)
.ok_or_else(|| field_not_found(col.relation.clone(), &col.name, self))
}

Expand Down
Loading

0 comments on commit 5c86db0

Please sign in to comment.