charlesdong1991 commented on code in PR #418:
URL: https://github.com/apache/fluss-rust/pull/418#discussion_r2889739163


##########
crates/fluss/src/metadata/datatype.rs:
##########
@@ -1582,116 +1475,25 @@ fn test_timestamp_ltz_invalid_precision() {
     );
 }
 
-// ============================================================================
-// RowType projection tests
-// ============================================================================
-
-#[test]
-fn test_row_type_project_valid_indices() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
-    );
-
-    // Valid projection by indices: [0, 2]
-    let projected = row_type.project(&[0, 2]).unwrap();
-    assert_eq!(projected.fields().len(), 2);
-    assert_eq!(projected.fields()[0].name, "id");
-    assert_eq!(projected.fields()[1].name, "age");
-}
-
-#[test]
-fn test_row_type_project_empty_indices() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
-    );
-
-    // Projection with an empty indices array should yield an empty RowType
-    let projected = row_type.project(&[]).unwrap();
-    assert_eq!(projected.fields().len(), 0);
-}
-
 #[test]
-fn test_row_type_project_with_field_names_valid() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
+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(),
     );
-
-    // Valid projection by names: ["id", "name"]
-    let projected = row_type
-        .project_with_field_names(&["id".to_string(), "name".to_string()])
-        .unwrap();
-    assert_eq!(projected.fields().len(), 2);
-    assert_eq!(projected.fields()[0].name, "id");
-    assert_eq!(projected.fields()[1].name, "name");
-}
-
-#[test]
-fn test_row_type_project_index_out_of_bounds() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
-    );
-
-    // Error: index out of bounds
-    let result = row_type.project(&[0, 5]);
-    assert!(result.is_err());
-    assert!(
-        result
-            .unwrap_err()
-            .to_string()
-            .contains("invalid field position: 5")
-    );
-}
-
-#[test]
-fn test_row_type_project_with_field_names_nonexistent() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
-    );
-
-    // Error: non-existent field name should throw exception
-    let result = 
row_type.project_with_field_names(&["nonexistent".to_string()]);
-    assert!(result.is_err());
-    assert!(
-        result
-            .unwrap_err()
-            .to_string()
-            .contains("Field 'nonexistent' does not exist in the row type")
-    );
-
-    // Mixed existing and non-existing: should also error on the first 
non-existent field
-    let result = row_type.project_with_field_names(&["id".to_string(), 
"nonexistent".to_string()]);
-    assert!(result.is_err());
-    assert!(
-        result
-            .unwrap_err()
-            .to_string()
-            .contains("Field 'nonexistent' does not exist in the row type")
+    assert_eq!(
+        field_with_desc.description(),
+        Some("Unique identifier for the user")
     );
-}
 
-#[test]
-fn test_row_type_project_duplicate_indices() {
-    // Create a 3-column row type
-    let row_type = RowType::with_data_types_and_field_names(
-        vec![DataTypes::int(), DataTypes::string(), DataTypes::bigint()],
-        vec!["id", "name", "age"],
-    );
+    // Test field without description
+    let field_no_desc = DataTypes::field("name", DataTypes::string());
+    assert_eq!(field_no_desc.description(), None);
 
-    // Projection with duplicate indices: [0, 0, 1]
-    // This documents the expected behavior - duplicates are allowed
-    let projected = row_type.project(&[0, 0, 1]).unwrap();
-    assert_eq!(projected.fields().len(), 3);
-    assert_eq!(projected.fields()[0].name, "id");
-    assert_eq!(projected.fields()[1].name, "id");
-    assert_eq!(projected.fields()[2].name, "name");
+    // Test that description() returns a reference to the description
+    let desc = field_with_desc.description();
+    assert!(desc.is_some());
+    assert_eq!(desc.unwrap(), "Unique identifier for the user");

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to