Copilot commented on code in PR #1264:
URL: https://github.com/apache/fluss/pull/1264#discussion_r2184487591


##########
fluss-common/src/main/java/com/alibaba/fluss/utils/PartitionUtils.java:
##########
@@ -134,4 +152,64 @@ public static String generateAutoPartitionTime(
     private static String getFormattedTime(ZonedDateTime zonedDateTime, String 
format) {
         return DateTimeFormatter.ofPattern(format).format(zonedDateTime);
     }
+
+    public static String convertValueOfType(Object value, DataTypeRoot type) {

Review Comment:
   The switch on `type` does not include a default case. If a new or 
unsupported DataTypeRoot is passed, the method returns an empty string 
silently. Consider adding a default branch that throws an 
IllegalArgumentException for unhandled types.



##########
fluss-common/src/test/java/com/alibaba/fluss/utils/PartitionUtilsTest.java:
##########
@@ -148,4 +154,173 @@ void testGenerateAutoPartitionName(
             
assertThat(resolvedPartitionSpec.getPartitionName()).isEqualTo(expected[i]);
         }
     }
+
+    @Test
+    void testString() {
+        Object value = BinaryString.fromString("Fluss");
+        DataTypeRoot type = DataTypeRoot.STRING;
+
+        String toStringResult = convertValueOfType(value, type);
+        assertThat(toStringResult).isEqualTo("Fluss");
+        String detectInvalid = detectInvalidName(toStringResult);
+        assertThat(detectInvalid).isEqualTo(null);
+    }
+
+    @Test
+    void testCharConvert() {
+        Object value = BinaryString.fromString("F");
+        DataTypeRoot type = DataTypeRoot.CHAR;
+
+        String toStringResult = convertValueOfType(value, type);
+        assertThat(toStringResult).isEqualTo("F");
+        String detectInvalid = detectInvalidName(toStringResult);
+        assertThat(detectInvalid).isEqualTo(null);
+    }
+
+    @Test
+    void testBooleanConvert() {
+        Object value = true;
+        DataTypeRoot type = DataTypeRoot.BOOLEAN;
+
+        String toStringResult = convertValueOfType(value, type);
+        assertThat(toStringResult).isEqualTo("true");
+        String detectInvalid = detectInvalidName(toStringResult);
+        assertThat(detectInvalid).isEqualTo(null);
+    }
+
+    @Test
+    void testByteConvert() {
+        Object value = new byte[] {0x10, 0x20, 0x30, 0x40, 0x50, (byte) 
0b11111111};
+        DataTypeRoot type = DataTypeRoot.BYTES;
+
+        String toStringResult = convertValueOfType(value, type);
+        assertThat(toStringResult).isEqualTo("1020304050ff");
+        String detectInvalid = detectInvalidName(toStringResult);
+        assertThat(detectInvalid).isEqualTo(null);
+    }
+
+    @Test
+    void testBinaryConvert() {
+        Object value = new byte[] {0x10, 0x20, 0x30, 0x40, 0x50, (byte) 
0b11111111};
+        DataTypeRoot type = DataTypeRoot.BINARY;
+
+        String toStringResult = convertValueOfType(value, type);
+        assertThat(toStringResult.equals("1020304050ff"));

Review Comment:
   This assertion checks a boolean but lacks a terminal assertion (e.g., 
`isTrue()`). Replace it with 
`assertThat(toStringResult).isEqualTo("1020304050ff");` for a clear failure 
message.
   ```suggestion
           assertThat(toStringResult).isEqualTo("1020304050ff");
   ```



-- 
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