Repository: pola-rs/polars
File: crates/polars-plan/src/plans/functions/dsl.rs (Rust)

Code before:
            DslFunction::Unpivot { args } => {
                let on = args.on.into_columns(input_schema, &Default::default())?;
                let index = args.index.into_columns(input_schema, &Default::default())?;

                let args = UnpivotArgsIR {
                    on: on.into_iter().collect(),
                    index: index.into_iter().collect(),
                    variable_name: args.variable_name.clone(),
                    value_name: args.value_name,
                };

                FunctionIR::Unpivot {
                    args: Arc::new(args),
                    schema: Default::default(),
                }
            },
            DslFunction::FunctionIR(func) => func,
            DslFunction::RowIndex { name, offset } => FunctionIR::RowIndex {
                name,
                offset,
                schema: Default::default(),
            },
            DslFunction::Unnest(selector) => {
                let columns = selector.into_columns(input_schema, &Default::default())?;
                let columns = columns.into_iter().collect();
                for col in Arc::clone(&columns).iter() {
                    let dtype = input_schema.try_get(col.as_str())?;
                    polars_ensure!(
                        dtype.is_struct(),
                        InvalidOperation: "invalid dtype: expected 'Struct', got '{:?}' for '{}'", dtype, col
                    );
                }
                FunctionIR::Unnest { columns }
            },
            #[cfg(feature = "python")]
            DslFunction::OpaquePython(inner) => FunctionIR::OpaquePython(inner),
            DslFunction::Stats(_)
            | DslFunction::FillNan(_)
            | DslFunction::Rename { .. }
            | DslFunction::Explode { .. } => {
                // We should not reach this.
                panic!("impl error")
            },
        };
        Ok(function)
    }
}

impl Debug for DslFunction {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "{self}")

Review comment (suggestion):
```suggestion
                for col in columns.iter() {
```

Code after:
            DslFunction::Unpivot { args } => {
                let on = args.on.into_columns(input_schema, &Default::default())?;
                let index = args.index.into_columns(input_schema, &Default::default())?;

                let args = UnpivotArgsIR {
                    on: on.into_iter().collect(),
                    index: index.into_iter().collect(),
                    variable_name: args.variable_name.clone(),
                    value_name: args.value_name,
                };

                FunctionIR::Unpivot {
                    args: Arc::new(args),
                    schema: Default::default(),
                }
            },
            DslFunction::FunctionIR(func) => func,
            DslFunction::RowIndex { name, offset } => FunctionIR::RowIndex {
                name,
                offset,
                schema: Default::default(),
            },
            DslFunction::Unnest(selector) => {
                let columns = selector.into_columns(input_schema, &Default::default())?;
                let columns: Arc<[PlSmallStr]> = columns.into_iter().collect();
                for col in columns.iter() {
                    let dtype = input_schema.try_get(col.as_str())?;
                    polars_ensure!(
                        dtype.is_struct(),
                        InvalidOperation: "invalid dtype: expected 'Struct', got '{:?}' for '{}'", dtype, col
                    );
                }
                FunctionIR::Unnest { columns }
            },
            #[cfg(feature = "python")]
            DslFunction::OpaquePython(inner) => FunctionIR::OpaquePython(inner),
            DslFunction::Stats(_)
            | DslFunction::FillNan(_)
            | DslFunction::Rename { .. }
            | DslFunction::Explode { .. } => {
                // We should not reach this.
                panic!("impl error")
            },
        };
        Ok(function)
    }
}

impl Debug for DslFunction {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "{self}")