MCPcopy Create free account
hub / github.com/apache/datafusion / from_indices

Method from_indices

datafusion/physical-expr/src/projection.rs:229–239  ·  view source on GitHub ↗

Creates a [`ProjectionExpr`] from a list of column indices. This is a convenience method for creating simple column-only projections, where each projection expression is a reference to a column in the input schema. # Behavior - Ordering: the output projection preserves the exact order of indices provided in the input slice For example, `[2, 0, 1]` will produce projections for columns 2, 0, then

(indices: &[usize], schema: &Schema)

Source from the content-addressed store, hash-verified

227 /// assert_eq!(projection_with_dups.as_ref()[2].alias, "b");
228 /// ```
229 pub fn from_indices(indices: &[usize], schema: &Schema) -> Self {
230 let projection_exprs = indices.iter().map(|&i| {
231 let field = schema.field(i);
232 ProjectionExpr {
233 expr: Arc::new(Column::new(field.name(), i)),
234 alias: field.name().clone(),
235 }
236 });
237
238 Self::from_iter(projection_exprs)
239 }
240
241 /// Returns an iterator over the projection expressions
242 pub fn iter(&self) -> impl Iterator<Item = &ProjectionExpr> {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
mapMethod · 0.45
iterMethod · 0.45
fieldMethod · 0.45
nameMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected