Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion datafusion/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Comment thread
nuno-faria marked this conversation as resolved.
Outdated
"optimizer" => self.optimizer.set(rem, value),
"explain" => self.explain.set(rem, value),
"sql_parser" => self.sql_parser.set(rem, value),
Expand Down
8 changes: 5 additions & 3 deletions datafusion/execution/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Comment thread
nuno-faria marked this conversation as resolved.
self
}

Expand Down
33 changes: 33 additions & 0 deletions datafusion/sqllogictest/test_files/information_schema.slt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,39 @@ drop table t
statement ok
drop table t2


############
## 0 to represent the default value (target_partitions and planning_concurrency)
###########

statement ok
SET datafusion.execution.target_partitions = 3;

statement ok
SET datafusion.execution.planning_concurrency = 3;

# when setting target_partitions and planning_concurrency to 3, their values will be 3
query TB rowsort
SELECT name, value = 3 FROM information_schema.df_settings WHERE name IN ('datafusion.execution.target_partitions', 'datafusion.execution.planning_concurrency');
----
datafusion.execution.planning_concurrency true
datafusion.execution.target_partitions true

statement ok
SET datafusion.execution.target_partitions = 0;

statement ok
SET datafusion.execution.planning_concurrency = 0;

# when setting target_partitions and planning_concurrency to 0, their values will be equal to the
# default values, which are different from 0 (which is invalid)
query TB rowsort
SELECT name, value = 0 FROM information_schema.df_settings WHERE name IN ('datafusion.execution.target_partitions', 'datafusion.execution.planning_concurrency');
----
datafusion.execution.planning_concurrency false
datafusion.execution.target_partitions false


############
## SHOW VARIABLES should work
###########
Expand Down