zhang-jianq commented on code in PR #13670:
URL: https://github.com/apache/gluten/pull/13670#discussion_r4680104688
##########
gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/HashFunctionsTest.java:
##########
@@ -91,6 +95,67 @@ void testSha1() {
"+I[null]"));
}
+ // Flink's hash expressions also accept BYTES and digest the raw bytes. The
+ // BYTES operand comes from a column cast, so the digest is computed at
+ // runtime (a literal would be constant-folded) by the VARBINARY signature.
+ // Non-UTF-8 bytes cannot be built with a cast; see
+ // testMd5Sha1BinarySourceColumn 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 BYTES source column: the raw-format filesystem source is not
+ // offloaded, so each file arrives as RowData and crosses the Flink -> velox
+ // boundary through the VARBINARY Arrow writer. "nonutf8" pins a NUL plus a
+ // non-UTF-8 byte, so the digests can only come from the raw bytes.
+ @Test
+ void testMd5Sha1BinarySourceColumn(@TempDir File dataDir) throws Exception {
Review Comment:
Thank you for review. `testBinaryProjectionCollectsUnchanged` projects the
raw BYTES column of the raw-format filesystem source through a collect sink and
asserts the `byte[]` values come back unchanged — `ab`, a NUL + non-UTF-8 byte,
and 你好's UTF-8 bytes. The test reads the `Row` fields directly, as the print
connector cannot carry VARBINARY. A folded `CAST('ab' AS BYTES)` constant is
projected alongside, which also covers the VARBINARY constant path.
--
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]