martin-g commented on code in PR #20372:
URL: https://github.com/apache/datafusion/pull/20372#discussion_r2877412880


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -1266,6 +1278,51 @@ 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'
+    ///
+    /// # Examples
+    /// ```
+    /// use datafusion::execution::context::SessionContext;
+    ///
+    /// assert_eq!(
+    ///     
SessionContext::parse_capacity_limit("datafusion.runtime.memory_limit", 
"1M").unwrap(),
+    ///     1024 * 1024
+    /// );
+    /// assert_eq!(
+    ///     
SessionContext::parse_capacity_limit("datafusion.runtime.memory_limit", 
"1.5G").unwrap(),
+    ///     (1.5 * 1024.0 * 1024.0 * 1024.0) as usize
+    /// );
+    /// ```
+    pub fn parse_capacity_limit(config_name: &str, limit: &str) -> 
Result<usize> {
+        if limit.trim().is_empty() {
+            return Err(plan_datafusion_err!(
+                "Empty limit value found for '{config_name}'"

Review Comment:
   Please add a test case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to