Skip to content

Commit 875829b

Browse files
authored
feat: Add projection pushdown to new streaming multiscan (#21139)
1 parent 1aab51c commit 875829b

File tree

7 files changed

+413
-204
lines changed

7 files changed

+413
-204
lines changed

crates/polars-core/src/schema.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::fmt::Debug;
22

3+
use arrow::bitmap::Bitmap;
34
use polars_utils::pl_str::PlSmallStr;
45

56
use crate::prelude::*;
@@ -20,6 +21,9 @@ pub trait SchemaExt {
2021
fn iter_fields(&self) -> impl ExactSizeIterator<Item = Field> + '_;
2122

2223
fn to_supertype(&mut self, other: &Schema) -> PolarsResult<bool>;
24+
25+
/// Select fields using a bitmap.
26+
fn project_select(&self, select: &Bitmap) -> Self;
2327
}
2428

2529
impl SchemaExt for Schema {
@@ -88,6 +92,15 @@ impl SchemaExt for Schema {
8892
}
8993
Ok(changed)
9094
}
95+
96+
fn project_select(&self, select: &Bitmap) -> Self {
97+
assert_eq!(self.len(), select.len());
98+
self.iter()
99+
.zip(select.iter())
100+
.filter(|(_, select)| *select)
101+
.map(|((n, dt), _)| (n.clone(), dt.clone()))
102+
.collect()
103+
}
91104
}
92105

93106
pub trait SchemaNamesAndDtypes {

0 commit comments

Comments
 (0)