Skip to content

Commit

Permalink
feat: Add projection pushdown to new streaming multiscan
Browse files Browse the repository at this point in the history
  • Loading branch information
coastalwhite committed Feb 7, 2025
1 parent 1145ec0 commit 2647bf6
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 204 deletions.
13 changes: 13 additions & 0 deletions crates/polars-core/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::Debug;

use arrow::bitmap::Bitmap;
use polars_utils::pl_str::PlSmallStr;

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

fn to_supertype(&mut self, other: &Schema) -> PolarsResult<bool>;

/// Select fields using a bitmap.
fn project_select(&self, select: &Bitmap) -> Self;
}

impl SchemaExt for Schema {
Expand Down Expand Up @@ -88,6 +92,15 @@ impl SchemaExt for Schema {
}
Ok(changed)
}

fn project_select(&self, select: &Bitmap) -> Self {
assert_eq!(self.len(), select.len());
self.iter()
.zip(select.iter())
.filter(|(_, select)| *select)
.map(|((n, dt), _)| (n.clone(), dt.clone()))
.collect()
}
}

pub trait SchemaNamesAndDtypes {
Expand Down
Loading

0 comments on commit 2647bf6

Please sign in to comment.