Skip to content

Commit 2b4517c

Browse files
committed
Added Description getter method for DataField
1 parent ee8beee commit 2b4517c

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

crates/fluss/src/metadata/datatype.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,11 @@ impl DataField {
11931193
pub fn data_type(&self) -> &DataType {
11941194
&self.data_type
11951195
}
1196+
1197+
/// Returns the description of the field, if any.
1198+
pub fn description(&self) -> Option<&str> {
1199+
self.description.as_deref()
1200+
}
11961201
}
11971202

11981203
impl Display for DataField {
@@ -1695,3 +1700,25 @@ fn test_row_type_project_duplicate_indices() {
16951700
assert_eq!(projected.fields()[1].name, "id");
16961701
assert_eq!(projected.fields()[2].name, "name");
16971702
}
1703+
1704+
#[test]
1705+
fn test_datafield_description() {
1706+
// Test field with description
1707+
let field_with_desc = DataTypes::field_with_description(
1708+
"user_id",
1709+
DataTypes::bigint(),
1710+
"Unique identifier for the user".to_string(),
1711+
);
1712+
assert_eq!(
1713+
field_with_desc.description(),
1714+
Some("Unique identifier for the user")
1715+
);
1716+
1717+
// Test field without description
1718+
let field_no_desc = DataTypes::field("name", DataTypes::string());
1719+
assert_eq!(field_no_desc.description(), None);
1720+
1721+
// Test that description() returns a reference to the description
1722+
let desc = field_with_desc.description();
1723+
assert_eq!(desc.unwrap(), "Unique identifier for the user");
1724+
}

0 commit comments

Comments
 (0)