Skip to content
Open
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
6 changes: 5 additions & 1 deletion datafusion/core/src/execution/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ impl SessionContext {
}

/// Parse capacity limit from string to number of bytes by allowing units: K, M and G.
/// Supports formats like '1.5G', '100M', '512K'
/// Supports formats like '1.5G', '100M', '512K'. Capacity limit can be set to 0 with '0'.
///
/// # Examples
/// ```
Expand All @@ -1296,6 +1296,9 @@ impl SessionContext {
"Empty limit value found for '{config_name}'"
));
}
if limit == "0" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition to cover the helper directly 👍

Since the intended user-facing flow is SET datafusion.runtime.* = '0', it could also be helpful to add a small SQL-level regression test or SLT that exercises something like SET datafusion.runtime.memory_limit = '0' and verifies SHOW returns the expected value.

That would help catch any future wiring regressions between the parser and the config layer.

return Ok(0);
}
let (number, unit) = limit.split_at(limit.len() - 1);
let number: f64 = number.parse().map_err(|_| {
plan_datafusion_err!(
Expand Down Expand Up @@ -2970,6 +2973,7 @@ mod tests {

// Valid capacity_limit
for (limit, want) in [
("0", 0),
("1.5K", (1.5 * 1024.0) as usize),
("2M", (2f64 * 1024.0 * 1024.0) as usize),
("1G", (1f64 * 1024.0 * 1024.0 * 1024.0) as usize),
Expand Down
Loading