Copilot commented on code in PR #61846:
URL: https://github.com/apache/doris/pull/61846#discussion_r3007328815


##########
regression-test/suites/query_p0/sql_functions/hash_functions/test_hash_function.groovy:
##########
@@ -32,6 +32,73 @@ suite("test_hash_function", "arrow_flight_sql") {
     qt_mmh3_64_v2_2 "SELECT MURMUR_HASH3_64_V2('1000209601_1756808272');"
     qt_mmh3_64_v2_3 "SELECT MURMUR_HASH3_64_V2('hello world');"
     qt_mmh3_64_v2_4 "SELECT MURMUR_HASH3_64_V2('apache doris');"
+    qt_mmh3_64_v2_5 "SELECT MURMUR_HASH3_64_V2('1013199993_1756808272');"
+    qt_mmh3_64_v2_6 "SELECT MURMUR_HASH3_64_V2('1020273884_1756808272');"
+
+    // murmur_hash3_u64_v2 tests
+    qt_mmh3_u64_v2_1 "SELECT MURMUR_HASH3_U64_V2(NULL);"
+    qt_mmh3_u64_v2_2 "SELECT MURMUR_HASH3_U64_V2('1000209601_1756808272');"
+    qt_mmh3_u64_v2_3 "SELECT MURMUR_HASH3_U64_V2('hello world');"
+    qt_mmh3_u64_v2_4 "SELECT MURMUR_HASH3_U64_V2('apache doris');"
+    qt_mmh3_u64_v2_5 "SELECT MURMUR_HASH3_U64_V2('1013199993_1756808272');"
+    qt_mmh3_u64_v2_6 "SELECT MURMUR_HASH3_U64_V2('1020273884_1756808272');"
+    qt_mmh3_u64_v2_7 "SELECT MURMUR_HASH3_U64_V2('');"
+    qt_mmh3_u64_v2_8 "SELECT MURMUR_HASH3_U64_V2('a');"
+    qt_mmh3_u64_v2_9 "SELECT MURMUR_HASH3_U64_V2('hello', 'world');"
+    qt_mmh3_u64_v2_10 "SELECT MURMUR_HASH3_U64_V2('hello', 'world', '!');"
+
+    // Validation: murmur_hash3_u64_v2 should equal (murmur_hash3_64_v2 & 
2^64-1)
+    def validate_mmh3_u64_v2 = { String... args ->
+        def argList = args.collect { "'${it}'" }.join(', ')

Review Comment:
   The helper builds SQL literals via "'${it}'" without escaping single quotes. 
If a future test string contains `'` or backslashes, this will generate invalid 
SQL (or change semantics). Consider escaping literals (e.g., replace `'` with 
`''`) or using a safer helper for SQL literal construction.
   ```suggestion
           def argList = args.collect { "'" + it.replace("\\", 
"\\\\").replace("'", "''") + "'" }.join(', ')
   ```



##########
regression-test/suites/query_p0/sql_functions/hash_functions/test_hash_function.groovy:
##########
@@ -32,6 +32,73 @@ suite("test_hash_function", "arrow_flight_sql") {
     qt_mmh3_64_v2_2 "SELECT MURMUR_HASH3_64_V2('1000209601_1756808272');"
     qt_mmh3_64_v2_3 "SELECT MURMUR_HASH3_64_V2('hello world');"
     qt_mmh3_64_v2_4 "SELECT MURMUR_HASH3_64_V2('apache doris');"
+    qt_mmh3_64_v2_5 "SELECT MURMUR_HASH3_64_V2('1013199993_1756808272');"
+    qt_mmh3_64_v2_6 "SELECT MURMUR_HASH3_64_V2('1020273884_1756808272');"
+
+    // murmur_hash3_u64_v2 tests
+    qt_mmh3_u64_v2_1 "SELECT MURMUR_HASH3_U64_V2(NULL);"
+    qt_mmh3_u64_v2_2 "SELECT MURMUR_HASH3_U64_V2('1000209601_1756808272');"
+    qt_mmh3_u64_v2_3 "SELECT MURMUR_HASH3_U64_V2('hello world');"
+    qt_mmh3_u64_v2_4 "SELECT MURMUR_HASH3_U64_V2('apache doris');"
+    qt_mmh3_u64_v2_5 "SELECT MURMUR_HASH3_U64_V2('1013199993_1756808272');"
+    qt_mmh3_u64_v2_6 "SELECT MURMUR_HASH3_U64_V2('1020273884_1756808272');"
+    qt_mmh3_u64_v2_7 "SELECT MURMUR_HASH3_U64_V2('');"
+    qt_mmh3_u64_v2_8 "SELECT MURMUR_HASH3_U64_V2('a');"
+    qt_mmh3_u64_v2_9 "SELECT MURMUR_HASH3_U64_V2('hello', 'world');"
+    qt_mmh3_u64_v2_10 "SELECT MURMUR_HASH3_U64_V2('hello', 'world', '!');"
+
+    // Validation: murmur_hash3_u64_v2 should equal (murmur_hash3_64_v2 & 
2^64-1)
+    def validate_mmh3_u64_v2 = { String... args ->
+        def argList = args.collect { "'${it}'" }.join(', ')
+        def u64_res = sql "SELECT MURMUR_HASH3_U64_V2(${argList});"
+        def v2_masked = sql "SELECT CAST(MURMUR_HASH3_64_V2(${argList}) AS 
LARGEINT) & 18446744073709551615;"
+        assertEquals(u64_res, v2_masked);
+    }
+
+    validate_mmh3_u64_v2('1000209601_1756808272');
+    validate_mmh3_u64_v2('hello world');
+    validate_mmh3_u64_v2('apache doris');
+    validate_mmh3_u64_v2('1013199993_1756808272');
+    validate_mmh3_u64_v2('1020273884_1756808272');
+    validate_mmh3_u64_v2('');
+    validate_mmh3_u64_v2('a');
+    validate_mmh3_u64_v2('你好🤣');
+    validate_mmh3_u64_v2('アパッチドリス');
+
+    // Table-based tests for mmh3_64_v2 and mmh3_u64_v2
+    sql "DROP TABLE IF EXISTS test_hash_tbl;"
+    sql """
+        CREATE TABLE test_hash_tbl (
+            id INT,
+            str_col VARCHAR(100)
+        ) DUPLICATE KEY(id)
+        DISTRIBUTED BY HASH(id) BUCKETS 1
+        PROPERTIES ("replication_num" = "1");
+    """
+
+    sql """
+        INSERT INTO test_hash_tbl VALUES
+        (1, '1000209601_1756808272'),
+        (2, 'hello world'),
+        (3, NULL),
+        (4, ''),
+        (5, 'apache doris'),
+        (6, '1013199993_1756808272'),
+        (7, '1020273884_1756808272'),
+        (8, '你好🤣'),
+        (9, 'アパッチドリス');
+    """
+
+    qt_mmh3_64_v2_table "SELECT id, MURMUR_HASH3_64_V2(str_col) FROM 
test_hash_tbl ORDER BY id;"
+    qt_mmh3_u64_v2_table "SELECT id, MURMUR_HASH3_U64_V2(str_col) FROM 
test_hash_tbl ORDER BY id;"
+
+    sql "DROP TABLE IF EXISTS test_hash_tbl;"
+
+    // Constant folding tests
+    qt_mmh3_64_v2_fold_1 "SELECT MURMUR_HASH3_64_V2('test') + 1;"
+    qt_mmh3_64_v2_fold_2 "SELECT MURMUR_HASH3_64_V2('a', 'b') * 2;"
+    qt_mmh3_u64_v2_fold_1 "SELECT MURMUR_HASH3_U64_V2('test') + 1;"
+    qt_mmh3_u64_v2_fold_2 "SELECT MURMUR_HASH3_U64_V2('a', 'b') * 2;"

Review Comment:
   These queries labeled as "Constant folding tests" only validate the computed 
value, not that folding is actually happening. To test constant folding 
behavior, use the suite helper `check_fold_consistency` (compares FE-folded, 
BE-folded, and no-fold results) or otherwise assert plan differences under the 
relevant session vars.
   ```suggestion
       check_fold_consistency {
           sql "SELECT MURMUR_HASH3_64_V2('test') + 1;"
       }
       check_fold_consistency {
           sql "SELECT MURMUR_HASH3_64_V2('a', 'b') * 2;"
       }
       check_fold_consistency {
           sql "SELECT MURMUR_HASH3_U64_V2('test') + 1;"
       }
       check_fold_consistency {
           sql "SELECT MURMUR_HASH3_U64_V2('a', 'b') * 2;"
       }
   ```



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