ctsk commented on code in PR #15712: URL: https://github.com/apache/datafusion/pull/15712#discussion_r2044124081
########## datafusion/common/src/config.rs: ########## @@ -768,7 +768,18 @@ impl ConfigField for ConfigOptions { let (key, rem) = key.split_once('.').unwrap_or((key, "")); match key { "catalog" => self.catalog.set(rem, value), - "execution" => self.execution.set(rem, value), + "execution" => { + let value = match (rem, value) { + ("target_partitions", "0") => { + &ExecutionOptions::default().target_partitions.to_string() + } + ("planning_concurrency", "0") => { + &ExecutionOptions::default().planning_concurrency.to_string() + } + _ => value, + }; + self.execution.set(rem, value) + } Review Comment: I'd make this a transform - a single dedicated function should work, since both `target_partitions` and `planning_concurrency` default to `get_available_parallelism` Something like: ```rs fn normalized_parallelism(n: &str) -> String { if n.parse::<usize>() == Ok(0) { get_available_parallelism().to_string() } else { n.to_owned() } } ``` ########## datafusion/execution/src/config.rs: ########## @@ -193,9 +193,11 @@ impl SessionConfig { /// /// [`target_partitions`]: datafusion_common::config::ExecutionOptions::target_partitions pub fn with_target_partitions(mut self, n: usize) -> Self { - // partition count must be greater than zero - assert!(n > 0); - self.options.execution.target_partitions = n; + self.options.execution.target_partitions = if n == 0 { + datafusion_common::config::ExecutionOptions::default().target_partitions + } else { + n + }; Review Comment: 👍 -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org