zhang-jianq commented on code in PR #13670:
URL: https://github.com/apache/gluten/pull/13670#discussion_r4750484251


##########
gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/HashFunctionsTest.java:
##########
@@ -91,6 +97,151 @@ void testSha1() {
             "+I[null]"));
   }
 
+  // BYTES via a column cast (a literal would fold); non-UTF-8 bytes need the
+  // source-column test below.
+  @Test
+  void testMd5Sha1Sha256VarbinaryInput() {
+    List<Row> rows =
+        Arrays.asList(Row.of("", 1), Row.of("ab", 2), Row.of("你好", 3), 
Row.of(null, 4));
+    createSimpleBoundedValuesTable("tblHashBinary", "s varchar, a int", rows);
+    runAndCheck(
+        "select MD5(CAST(s AS BYTES)), SHA1(CAST(s AS BYTES)), SHA256(CAST(s 
AS BYTES))"
+            + " from tblHashBinary where a > 0",
+        Arrays.asList(
+            "+I["
+                + MD5_EMPTY
+                + ", "
+                + SHA1_EMPTY
+                + ", 
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]",
+            "+I[187ef4436122d1cc2f40dc2b92f0eba0, "
+                + "da23614e02469a0d7c7bd1bdab5c9c474b1904dc, "
+                + 
"fb8e20fc2e4c3f248c60c39bd652f3c1347298bb977b8b4d5903b85055620603]",
+            "+I[7eca689f0d3389d9dea66ae112e5cfd7, "
+                + "440ee0853ad1e99f962b63e459ef992d7c211722, "
+                + 
"670d9743542cae3ea7ebe36af56bd53648b0a1126162e78d81a32934a711302e]",
+            "+I[null, null, null]"));
+  }
+
+  // A genuine raw-file BYTES column crossing the Flink -> velox boundary;
+  // "nonutf8" (a NUL + non-UTF-8 byte) proves the digests come from raw bytes.
+  @Test
+  void testMd5Sha1BinarySourceColumn(@TempDir File dataDir) throws Exception {
+    Files.write(new File(dataDir, "ab").toPath(), new byte[] {0x61, 0x62});
+    Files.write(new File(dataDir, "nonutf8").toPath(), new byte[] {0x00, 
(byte) 0xFF, 0x10});
+    Files.write(new File(dataDir, "utf8").toPath(), 
"你好".getBytes(StandardCharsets.UTF_8));
+    tEnv()
+        .executeSql(
+            "CREATE TABLE binSrc (`value` BYTES) WITH ("
+                + "'connector' = 'filesystem',"
+                + "'path' = '"
+                + dataDir.toURI()
+                + "',"
+                + "'format' = 'raw')");
+    // The print sink prefixes rows with the parallel subtask ("3> +I[...]").
+    List<String> rows =
+        runQuery("select MD5(`value`), SHA1(`value`) from binSrc").stream()
+            .map(row -> row.replaceFirst("^\\d+> ", ""))
+            .collect(java.util.stream.Collectors.toList());

Review Comment:
   Thank you for review, it's done `​java.util.stream.Collectors`​ is imported 
and the call site shortened.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to