From 46c1447eaaa77a9304fb46c47b467324863c8394 Mon Sep 17 00:00:00 2001 From: Michael Kleen Date: Tue, 5 May 2026 06:34:32 +0200 Subject: [PATCH] Support '0' value for parse_capacity_limit --- datafusion/core/src/execution/context/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rs index 87170f595f413..d84ef0c898313 100644 --- a/datafusion/core/src/execution/context/mod.rs +++ b/datafusion/core/src/execution/context/mod.rs @@ -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 /// ``` @@ -1296,6 +1296,9 @@ impl SessionContext { "Empty limit value found for '{config_name}'" )); } + if limit == "0" { + return Ok(0); + } let (number, unit) = limit.split_at(limit.len() - 1); let number: f64 = number.parse().map_err(|_| { plan_datafusion_err!( @@ -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),