github-actions[bot] commented on code in PR #68438:
URL: https://github.com/apache/doris/pull/68438#discussion_r4091681128


##########
be/src/exprs/function/array/function_array_shuffle.cpp:
##########
@@ -70,16 +72,24 @@ class FunctionArrayShuffle : public IFunction {
                 
block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
         const auto& src_column_array = assert_cast<const 
ColumnArray&>(*src_column);
 
-        size_t seed = time(nullptr);
+        ColumnPtr dest_column_ptr;
         if (arguments.size() == 2) {
-            ColumnPtr seed_column =
-                    
block.get_by_position(arguments[1]).column->convert_to_full_column_if_const();
-            seed = assert_cast<const 
ColumnInt64*>(seed_column.get())->get_element(0);
+            const auto [seed_column, seed_const] =
+                    
unpack_if_const(block.get_by_position(arguments[1]).column);
+            const auto& seeds = assert_cast<const 
ColumnInt64&>(*seed_column).get_data();
+            // Each row re-seeds with its own seed, so the result of a row only
+            // depends on its array and seed, not on the rows before it.
+            std::mt19937_64 g;

Review Comment:
   [P1] Preserve seeded output across rolling upgrades
   
   Switching engines changes `array_shuffle([1,2,3,4,5], 0)` from `[3, 5, 4, 1, 
2]` to `[3, 1, 2, 4, 5]` even for a single-row call, as the changed doc golden 
shows. `ArrayShuffle` has no FE evaluator, so constants are executed by each 
BE, and this registration has no old implementation selected by 
`be_exec_version`. During a rolling upgrade, a distributed query such as 
`SELECT DISTINCT array_shuffle([1,2,3,4,5], 0) FROM t` can therefore return 
both permutations for a seeded result that is supposed to be reproducible. 
Please preserve the legacy `mt19937` mapping for previously supported seeds 
(and leave the unrelated no-seed engine unchanged), or version/alias-gate the 
new all-BIGINT algorithm so every BE in one query uses the same semantics.



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