Doris-Breakwater commented on issue #71208:
URL: https://github.com/apache/doris/issues/71208#issuecomment-7303298153

   Breakwater-GitHub-Analysis-Slot: slot_a55c5305c18e
   
   **Triage.** This is the same BE aggregate-state serialization defect 
reported in [#69931](https://github.com/apache/doris/issues/69931), with two 
additional regression cases. The screenshots show a two-field struct failing 
with `agg_phase = 2` and returning an array of 10 elements with `agg_phase = 
1`. The trailing-backslash case also fails in phase 2. The table-free 
reproduction uses this query.
   
   ```sql
   SET agg_phase = 2;
   SELECT SIZE(ARRAY_AGG(NAMED_STRUCT('id', number, 'v', '3/4"')))
   FROM numbers('number' = '10');
   ```
   
   **Verified in source.** On the reported build commit `54d154ce8e8`, 
`NAMED_STRUCT` produces a non-nullable outer struct, so `ARRAY_AGG` takes the 
complex `COLLECT_LIST` path even when its struct fields are nullable. 
`AggregateFunctionCollectListData::write/read` sends each partial-state element 
through text SerDe with `escape_char = 0`. The nested STRING writer adds 
surrounding quotes and copies the payload verbatim. The STRUCT reader tracks 
matching quotes and skips the byte after a backslash. In the supplied examples, 
the embedded double quote closes the quoted span early or the trailing 
backslash skips the closing quote. Either leaves the parser in a quoted span at 
the end, where it skips the final field and raises the reported field-count 
error. The text state path is also present in the checked upstream `branch-4.1` 
and `master` snapshots. [4.1 aggregate 
state](https://github.com/apache/doris/blob/e805958fdc3d4ba7de7c0b9d2145eca4f69b1b11/be/src/exprs/aggregate/aggregate_funct
 ion_collect.h#L342-L387) · [STRUCT 
parser](https://github.com/apache/doris/blob/e805958fdc3d4ba7de7c0b9d2145eca4f69b1b11/be/src/core/data_type_serde/data_type_struct_serde.cpp#L185-L295)
 · [master aggregate 
state](https://github.com/apache/doris/blob/c853a51fe84ef12ad1fc31a3816aae0c493d8463/be/src/exprs/aggregate/aggregate_function_collect.h#L355-L400)
   
   **What to verify.** A standalone model of the field scanner recovered one of 
two fields for both failing inputs. It also suggests that the earlier `x", "y` 
example can return the expected array size while recovering only `x` when the 
string is the last field. Please check that case on a running BE and compare 
the extracted field bytes as well as the array size. The screenshots provide 
enough to start the regression. To check whether plan selection explains the 
intermittent behavior under `agg_phase = 0`, please share redacted `EXPLAIN 
VERBOSE` output for the affected `INSERT … SELECT` with and without the 
statement hint. If a session-level `SET` still behaves differently, capture 
`SELECT @@agg_phase` on the connection that runs the insert.
   
   **Next steps.** Keep the reported `SELECT /*+ SET_VAR(agg_phase = 1) */ …` 
workaround scoped to the affected statement and check the plan for a single 
aggregation stage for this expression. For the fix, consider native typed 
serialization for the complex collect state, preserving the `COLLECT_LIST` 
limit and merge behavior. Gate any wire-format change for mixed-version BEs 
during rolling upgrades. Add phase 1 and phase 2 regression coverage for both 
functions with a single double quote, one trailing backslash, embedded 
backslashes, and a pair of double quotes with a comma between them. Include 
cases where another field follows the affected string. Assert the recovered 
bytes as well as the field and element counts. [Native complex-state 
precedent](https://github.com/apache/doris/pull/66601)
   


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