How to project Schema
or SchemaDescriptor
by ProjectionMask
?
#4695
-
Suppose we have a parquet file whose schema is We can construct a My question is, how can I precompute the output I only found impl Schema {
pub fn project(&self, indices: &[usize]) -> Result<Schema, ArrowError> {
let new_fields = indices
.iter()
.map(|i| {
self.fields.get(*i).cloned().ok_or_else(|| {
ArrowError::SchemaError(format!(
"project index {} out of bounds, max field {}",
i,
self.fields().len()
))
})
})
.collect::<Result<Vec<_>, _>>()?;
Ok(Self::new_with_metadata(new_fields, self.metadata.clone()))
}
} which only can project root fields. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't believe we support this directly on arrow Schema yet, but there is https://docs.rs/parquet/latest/parquet/arrow/fn.parquet_to_arrow_schema_by_columns.html |
Beta Was this translation helpful? Give feedback.
I don't believe we support this directly on arrow Schema yet, but there is https://docs.rs/parquet/latest/parquet/arrow/fn.parquet_to_arrow_schema_by_columns.html