Skip to content

Commit 97ff345

Browse files
yahoNanJingyangzhong
andauthored
Print the configurations of ConfigOptions in an ordered way so that we can directly compare the equality of two ConfigOptions by their debug strings (apache#3953)
Co-authored-by: yangzhong <yangzhong@ebay.com>
1 parent 10e64dc commit 97ff345

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

datafusion/core/src/config.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ use datafusion_common::ScalarValue;
2222
use itertools::Itertools;
2323
use log::warn;
2424
use parking_lot::RwLock;
25-
use std::collections::HashMap;
25+
use std::collections::{BTreeMap, HashMap};
2626
use std::env;
27+
use std::fmt::{Debug, Formatter};
2728
use std::sync::Arc;
2829

2930
/// Configuration option "datafusion.optimizer.filter_null_join_keys"
@@ -274,11 +275,23 @@ impl BuiltInConfigs {
274275
}
275276

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

283+
/// Print the configurations in an ordered way so that we can directly compare the equality of two ConfigOptions by their debug strings
284+
impl Debug for ConfigOptions {
285+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
286+
f.debug_struct("ConfigOptions")
287+
.field(
288+
"options",
289+
&format!("{:?}", BTreeMap::from_iter(self.options.iter())),
290+
)
291+
.finish()
292+
}
293+
}
294+
282295
impl Default for ConfigOptions {
283296
fn default() -> Self {
284297
Self::new()

0 commit comments

Comments
 (0)