Skip to content

Commit

Permalink
Print the configurations of ConfigOptions in an ordered way so that w…
Browse files Browse the repository at this point in the history
…e can directly compare the equality of two ConfigOptions by their debug strings (apache#3953)

Co-authored-by: yangzhong <yangzhong@ebay.com>
  • Loading branch information
2 people authored and Dandandan committed Nov 5, 2022
1 parent 323a5d9 commit 89b697b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions datafusion/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ use datafusion_common::ScalarValue;
use itertools::Itertools;
use log::warn;
use parking_lot::RwLock;
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use std::env;
use std::fmt::{Debug, Formatter};
use std::sync::Arc;

/// Configuration option "datafusion.optimizer.filter_null_join_keys"
Expand Down Expand Up @@ -274,11 +275,23 @@ impl BuiltInConfigs {
}

/// Configuration options struct. This can contain values for built-in and custom options
#[derive(Debug, Clone)]
#[derive(Clone)]
pub struct ConfigOptions {
options: HashMap<String, ScalarValue>,
}

/// Print the configurations in an ordered way so that we can directly compare the equality of two ConfigOptions by their debug strings
impl Debug for ConfigOptions {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConfigOptions")
.field(
"options",
&format!("{:?}", BTreeMap::from_iter(self.options.iter())),
)
.finish()
}
}

impl Default for ConfigOptions {
fn default() -> Self {
Self::new()
Expand Down

0 comments on commit 89b697b

Please sign in to comment.