Skip to content

Commit

Permalink
fix: format Hudi config enum should show the full config key (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal-Singh-Dadhwal authored Jan 22, 2025
1 parent af997b7 commit 3527f54
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/core/src/config/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! Hudi internal configurations.
use std::collections::HashMap;
use std::fmt::Display;
use std::str::FromStr;

use strum_macros::EnumIter;
Expand Down Expand Up @@ -52,6 +53,12 @@ impl AsRef<str> for HudiInternalConfig {
}
}

impl Display for HudiInternalConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())
}
}

impl ConfigParser for HudiInternalConfig {
type Output = HudiConfigValue;

Expand Down
7 changes: 7 additions & 0 deletions crates/core/src/config/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//! Hudi read configurations.
use std::collections::HashMap;
use std::fmt::Display;
use std::str::FromStr;

use strum_macros::EnumIter;
Expand Down Expand Up @@ -69,6 +70,12 @@ impl AsRef<str> for HudiReadConfig {
}
}

impl Display for HudiReadConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())
}
}

impl ConfigParser for HudiReadConfig {
type Output = HudiConfigValue;

Expand Down
24 changes: 23 additions & 1 deletion crates/core/src/config/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! Hudi table configurations.
use std::collections::HashMap;
use std::fmt::Display;
use std::str::FromStr;

use strum_macros::{AsRefStr, EnumIter};

use crate::config::error::ConfigError;
Expand Down Expand Up @@ -141,6 +141,12 @@ impl AsRef<str> for HudiTableConfig {
}
}

impl Display for HudiTableConfig {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_ref())
}
}

impl ConfigParser for HudiTableConfig {
type Output = HudiConfigValue;

Expand Down Expand Up @@ -416,4 +422,20 @@ mod tests {
InvalidValue(_)
));
}

#[test]
fn test_display_trait_implementation() {
assert_eq!(
format!("{}", HudiTableConfig::KeyGeneratorClass),
"hoodie.table.keygenerator.class"
);
assert_eq!(
format!("{}", HudiTableConfig::BaseFileFormat),
"hoodie.table.base.file.format"
);
assert_eq!(
format!("{}", HudiTableConfig::TableName),
"hoodie.table.name"
);
}
}

0 comments on commit 3527f54

Please sign in to comment.