alamb opened a new issue #1425: URL: https://github.com/apache/arrow-datafusion/issues/1425
**Background** @hntd187 fixed https://github.com/apache/arrow-datafusion/issues/1361 via https://github.com/apache/arrow-datafusion/pull/1378 but when I was reviewing the code, I found several other places that project `RecordBatch`s and `Schemas` that may also have the same subtle issues about losing the metadata. I am not sure of any bugs related to this yet but I fear they are lurking The basic idea is to make functions like ```rust fn project_schema(schema: &Schema, projection: &[usize]) -> <Schema> { ... } fn project_batch(batch: &RecordBatch, projection: &[usize]) -> Result<RecordBatch> { ... } ``` And replace the duplicated code like ```rust let projected_schema = match &projection { Some(columns) => { let fields: Result<Vec<Field>> = columns .iter() .map(|i| { if *i < schema.fields().len() { Ok(schema.field(*i).clone()) } else { Err(DataFusionError::Internal( "Projection index out of range".to_string(), )) } }) .collect(); Arc::new(Schema::new(fields?)) } None => Arc::clone(&schema), }; ``` ALl over the datafusion codebase **Additional context** Here is a corresponding arrow ticket to put the logic into arrow-rs: https://github.com/apache/arrow-rs/issues/1014 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
