-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: track memory usage for recursive CTE, enable recursive CTEs by default #9619
Changes from 7 commits
358c764
ef1b8c7
653369d
f243f23
77f737a
5392cb0
1c79dc2
2eb567d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ use super::{ | |
use arrow::datatypes::SchemaRef; | ||
use arrow::record_batch::RecordBatch; | ||
use datafusion_common::{internal_err, project_schema, Result}; | ||
use datafusion_execution::memory_pool::MemoryReservation; | ||
use datafusion_execution::TaskContext; | ||
use datafusion_physical_expr::{EquivalenceProperties, LexOrdering}; | ||
|
||
|
@@ -236,6 +237,8 @@ impl MemoryExec { | |
pub struct MemoryStream { | ||
/// Vector of record batches | ||
data: Vec<RecordBatch>, | ||
/// Optional memory reservation bound to the data, freed on drop | ||
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. I was a little worried at first that this optional API makes it easy to forget to provide reservation. However I see now that the reservation is used only with the recursive CTE case (not for this PR) In general I wondered if we should always have a memory reservation to 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. This concern is quite reasonable; previously there was no need to add a I plan to no longer use So that the |
||
reservation: Option<MemoryReservation>, | ||
/// Schema representing the data | ||
schema: SchemaRef, | ||
/// Optional projection for which columns to load | ||
|
@@ -253,11 +256,18 @@ impl MemoryStream { | |
) -> Result<Self> { | ||
Ok(Self { | ||
data, | ||
reservation: None, | ||
schema, | ||
projection, | ||
index: 0, | ||
}) | ||
} | ||
|
||
/// Set the memory reservation for the data | ||
pub(super) fn with_reservation(mut self, reservation: MemoryReservation) -> Self { | ||
self.reservation = Some(reservation); | ||
self | ||
} | ||
} | ||
|
||
impl Stream for MemoryStream { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍