Skip to content
Open
Changes from all 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
27 changes: 27 additions & 0 deletions crates/fluss/src/metadata/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,11 @@ impl DataField {
pub fn data_type(&self) -> &DataType {
&self.data_type
}

/// Returns the description of the field, if any.
pub fn description(&self) -> Option<&str> {
self.description.as_deref()
}
}

impl Display for DataField {
Expand Down Expand Up @@ -1695,3 +1700,25 @@ fn test_row_type_project_duplicate_indices() {
assert_eq!(projected.fields()[1].name, "id");
assert_eq!(projected.fields()[2].name, "name");
}

#[test]
fn test_datafield_description() {
// Test field with description
let field_with_desc = DataTypes::field_with_description(
"user_id",
DataTypes::bigint(),
"Unique identifier for the user".to_string(),
);
assert_eq!(
field_with_desc.description(),
Some("Unique identifier for the user")
);

// Test field without description
let field_no_desc = DataTypes::field("name", DataTypes::string());
assert_eq!(field_no_desc.description(), None);

// Test that description() returns a reference to the description
let desc = field_with_desc.description();
assert_eq!(desc.unwrap(), "Unique identifier for the user");
Comment on lines +1722 to +1723
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think tests here a bit redundant and re-verifies what the first assert_eq already did

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this, kept the unwrap assert to check if the actual description string matches what was originally passed

}