-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add field to DynamicPhysicalExpr to indicate when the filter is complete or updated #18799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dffd77b
278c3bb
32bbd7a
43d9fb2
3115cfb
d800cfa
e106696
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,10 +591,13 @@ impl TopK { | |
| common_sort_prefix_converter: _, | ||
| common_sort_prefix: _, | ||
| finished: _, | ||
| filter: _, | ||
| filter, | ||
| } = self; | ||
| let _timer = metrics.baseline.elapsed_compute().timer(); // time updated on drop | ||
|
|
||
| // Mark the dynamic filter as complete now that TopK processing is finished. | ||
| filter.read().expr().mark_complete(); | ||
|
|
||
| // break into record batches as needed | ||
| let mut batches = vec![]; | ||
| if let Some(mut batch) = heap.emit()? { | ||
|
|
@@ -1198,4 +1201,52 @@ mod tests { | |
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// This test verifies that the dynamic filter is marked as complete after TopK processing finishes. | ||
| #[tokio::test] | ||
| async fn test_topk_marks_filter_complete() -> Result<()> { | ||
| let schema = Arc::new(Schema::new(vec![Field::new("a", DataType::Int32, false)])); | ||
|
|
||
| let sort_expr = PhysicalSortExpr { | ||
| expr: col("a", schema.as_ref())?, | ||
| options: SortOptions::default(), | ||
| }; | ||
|
|
||
| let full_expr = LexOrdering::from([sort_expr.clone()]); | ||
| let prefix = vec![sort_expr]; | ||
|
|
||
| // Create a dummy runtime environment and metrics | ||
| let runtime = Arc::new(RuntimeEnv::default()); | ||
| let metrics = ExecutionPlanMetricsSet::new(); | ||
|
|
||
| // Create a dynamic filter that we'll check for completion | ||
| let dynamic_filter = Arc::new(DynamicFilterPhysicalExpr::new(vec![], lit(true))); | ||
| let dynamic_filter_clone = Arc::clone(&dynamic_filter); | ||
|
|
||
| // Create a TopK instance | ||
| let mut topk = TopK::try_new( | ||
| 0, | ||
| Arc::clone(&schema), | ||
| prefix, | ||
| full_expr, | ||
| 2, | ||
| 10, | ||
| runtime, | ||
| &metrics, | ||
| Arc::new(RwLock::new(TopKDynamicFilters::new(dynamic_filter))), | ||
| )?; | ||
|
|
||
| let array: ArrayRef = Arc::new(Int32Array::from(vec![Some(3), Some(1), Some(2)])); | ||
| let batch = RecordBatch::try_new(Arc::clone(&schema), vec![array])?; | ||
| topk.insert_batch(batch)?; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also do an assertion for 'in progress' here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the issue is that its hard to set up in the tests a |
||
| // Call emit to finish TopK processing | ||
| let _results: Vec<_> = topk.emit()?.try_collect().await?; | ||
|
|
||
| // After emit is called, the dynamic filter should be marked as complete | ||
| // wait_complete() should return immediately | ||
| dynamic_filter_clone.wait_complete().await; | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.