Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions datafusion/physical-plan/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,10 @@ impl ExecutionPlan for FilterExec {
})
}

fn fetch(&self) -> Option<usize> {
self.fetch
}

fn with_fetch(&self, fetch: Option<usize>) -> Option<Arc<dyn ExecutionPlan>> {
Some(Arc::new(Self {
predicate: Arc::clone(&self.predicate),
Expand Down
1 change: 1 addition & 0 deletions datafusion/proto/proto/datafusion.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ message FilterExecNode {
uint32 default_filter_selectivity = 3;
repeated uint32 projection = 9;
uint32 batch_size = 10;
optional uint32 fetch = 11;
}

message FileGroup {
Expand Down
19 changes: 19 additions & 0 deletions datafusion/proto/src/generated/pbjson.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions datafusion/proto/src/generated/prost.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions datafusion/proto/src/physical_plan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ impl protobuf::PhysicalPlanNode {
let filter = FilterExecBuilder::new(predicate, input)
.apply_projection(projection)?
.with_batch_size(filter.batch_size as usize)
.with_fetch(filter.fetch.map(|f| f as usize))
.build()?;
match filter_selectivity {
Ok(filter_selectivity) => Ok(Arc::new(
Expand Down Expand Up @@ -2334,6 +2335,7 @@ impl protobuf::PhysicalPlanNode {
v.iter().map(|x| *x as u32).collect::<Vec<u32>>()
}),
batch_size: exec.batch_size() as u32,
fetch: exec.fetch().map(|f| f as u32),
},
))),
})
Expand Down
13 changes: 13 additions & 0 deletions datafusion/proto/tests/cases/roundtrip_physical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,19 @@ fn roundtrip_filter_with_not_and_in_list() -> Result<()> {
)?))
}

#[test]
fn roundtrip_filter_with_fetch() -> Result<()> {
let field_a = Field::new("a", DataType::Boolean, false);
let field_b = Field::new("b", DataType::Int64, false);
let schema = Arc::new(Schema::new(vec![field_a, field_b]));
let predicate = col("a", &schema)?;
let filter = FilterExecBuilder::new(predicate, Arc::new(EmptyExec::new(schema)))
.with_fetch(Some(10))
.build()?;
assert_eq!(filter.fetch(), Some(10));
roundtrip_test(Arc::new(filter))
}

#[test]
fn roundtrip_sort() -> Result<()> {
let field_a = Field::new("a", DataType::Boolean, false);
Expand Down
Loading