morningman commented on code in PR #67476:
URL: https://github.com/apache/doris/pull/67476#discussion_r3925066255


##########
be/src/exprs/function/cast/cast_to_variant.h:
##########
@@ -125,6 +148,9 @@ inline Status cast_from_variant_impl(FunctionContext* 
context, Block& block,
                 return cast_from_generic_to_jsonb(context, finalized_block, 
arguments, result,
                                                   input_rows_count);

Review Comment:
   Deliberately not addressed in this PR: the mechanism is real, but it 
predates this change and I could not find a reachable path to it.
   
   `ColumnUInt8::create(col_from.size(), 0)` against a loop over 
`input_rows_count` has been there since #50940 (bd3c4539f8b, 2025-07-17), and 
`cast_from_generic_to_jsonb` is the shared generic-to-JSONB path for 
array/map/struct as well. If `input_rows_count < col_from.size()` were 
reachable, `CAST(<array> AS JSON)` would already throw today, independently of 
variant.
   
   Reachability is the same question as the prefix half of the sibling comment, 
and the answer is the same: every cast entry point passes the full row count 
(`vcast_expr.cpp:122`, `:171`), the per-row try_cast path passes a 1-row `cut` 
with count 1 (`:236`), `prepare_remove_nullable` forwards the count unchanged 
over same-size columns, and const arguments run through a temporary block sized 
by its own `rows()`.
   
   If you would like it hardened regardless, 
`ColumnUInt8::create(input_rows_count, 0)` is a no-op whenever the sizes agree. 
I would rather send that as a separate PR against the shared helper than widen 
this one, since it changes a function every generic-to-JSONB cast goes through. 
Happy to do that if a maintainer prefers.



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