erenavsarogullari commented on code in PR #20372:
URL: https://github.com/apache/datafusion/pull/20372#discussion_r2881728365
##########
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:
`test_parse_capacity_limit` test case already covers this case with
empty/blank capacity limit and all other negative cases:
https://github.com/apache/datafusion/pull/20372/changes#diff-ea1df26aafe37d2465b4a63a6460a3ea1757e0f5b16de7964dc48b96ba8ab27aR2871
`config_name` has been added to all error messages of `parse_capacity_limit`
function so only `config_name` is checked in error message.
##########
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:
`test_parse_capacity_limit` test case already covers this case with
empty/blank capacity limit and all other negative cases:
https://github.com/apache/datafusion/pull/20372/changes#diff-ea1df26aafe37d2465b4a63a6460a3ea1757e0f5b16de7964dc48b96ba8ab27aR2871
Also, `config_name` has been added to all error messages of
`parse_capacity_limit` function so only `config_name` is checked in error
message.
--
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]