This is an automated email from the ASF dual-hosted git repository.

xushiyan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hudi-rs.git


The following commit(s) were added to refs/heads/main by this push:
     new 3527f54  fix: format Hudi config enum should show the full config key 
(#254)
3527f54 is described below

commit 3527f54737d7195d69feaf9d58d56ac7e38b1179
Author: Hug_Bunter <[email protected]>
AuthorDate: Wed Jan 22 21:24:40 2025 +0530

    fix: format Hudi config enum should show the full config key (#254)
---
 crates/core/src/config/internal.rs |  7 +++++++
 crates/core/src/config/read.rs     |  7 +++++++
 crates/core/src/config/table.rs    | 24 +++++++++++++++++++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/crates/core/src/config/internal.rs 
b/crates/core/src/config/internal.rs
index 61e1a88..61f74c6 100644
--- a/crates/core/src/config/internal.rs
+++ b/crates/core/src/config/internal.rs
@@ -19,6 +19,7 @@
 //! Hudi internal configurations.
 
 use std::collections::HashMap;
+use std::fmt::Display;
 use std::str::FromStr;
 
 use strum_macros::EnumIter;
@@ -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;
 
diff --git a/crates/core/src/config/read.rs b/crates/core/src/config/read.rs
index 97d8a0f..91eaf0f 100644
--- a/crates/core/src/config/read.rs
+++ b/crates/core/src/config/read.rs
@@ -19,6 +19,7 @@
 //! Hudi read configurations.
 
 use std::collections::HashMap;
+use std::fmt::Display;
 use std::str::FromStr;
 
 use strum_macros::EnumIter;
@@ -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;
 
diff --git a/crates/core/src/config/table.rs b/crates/core/src/config/table.rs
index 9915626..9c73b76 100644
--- a/crates/core/src/config/table.rs
+++ b/crates/core/src/config/table.rs
@@ -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;
@@ -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;
 
@@ -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"
+        );
+    }
 }

Reply via email to