Skip to content

Commit 9c18ad3

Browse files
committed
Added Description getter method for DataField
1 parent 9877993 commit 9c18ad3

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

crates/fluss/src/metadata/datatype.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,11 @@ impl DataField {
11701170
pub fn data_type(&self) -> &DataType {
11711171
&self.data_type
11721172
}
1173+
1174+
/// Returns the description of the field, if any.
1175+
pub fn description(&self) -> Option<&str> {
1176+
self.description.as_deref()
1177+
}
11731178
}
11741179

11751180
impl Display for DataField {
@@ -1469,3 +1474,26 @@ fn test_timestamp_ltz_invalid_precision() {
14691474
.contains("Timestamp with local time zone precision must be between 0 and 9")
14701475
);
14711476
}
1477+
1478+
#[test]
1479+
fn test_datafield_description() {
1480+
// Test field with description
1481+
let field_with_desc = DataTypes::field_with_description(
1482+
"user_id",
1483+
DataTypes::bigint(),
1484+
"Unique identifier for the user".to_string(),
1485+
);
1486+
assert_eq!(
1487+
field_with_desc.description(),
1488+
Some("Unique identifier for the user")
1489+
);
1490+
1491+
// Test field without description
1492+
let field_no_desc = DataTypes::field("name", DataTypes::string());
1493+
assert_eq!(field_no_desc.description(), None);
1494+
1495+
// Test that description() returns a reference to the description
1496+
let desc = field_with_desc.description();
1497+
assert!(desc.is_some());
1498+
assert_eq!(desc.unwrap(), "Unique identifier for the user");
1499+
}

0 commit comments

Comments
 (0)