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)
| 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> { |