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


##########
be/src/udf/python/python_udf_meta.cpp:
##########
@@ -32,7 +32,6 @@ namespace doris {
 
 Status PythonUDFMeta::convert_types_to_schema(const DataTypes& types, const 
std::string& timezone,
                                               std::shared_ptr<arrow::Schema>* 
schema) {
-    assert(!types.empty());
     arrow::SchemaBuilder builder;
     for (size_t i = 0; i < types.size(); ++i) {

Review Comment:
   This branch now depends on `client_type` being initialized, but 
`PythonUDFMeta` still has no default member initializers. Today the production 
callers set it before `check()`, but a future default-constructed caller with 
empty `input_types` would read an indeterminate enum here. Defaulting `type` / 
`client_type` to `UNKNOWN` in the struct would make this safer.



##########
be/src/exprs/table_function/python_udtf_function.cpp:
##########
@@ -132,12 +132,19 @@ Status PythonUDTFFunction::process_init(Block* block, 
RuntimeState* state) {
     for (uint32_t i = 0; i < child_column_idxs.size(); ++i) {
         input_block.insert(block->get_by_position(child_column_idxs[i]));
     }
+    int64_t input_rows = block->rows();
     std::shared_ptr<arrow::Schema> input_schema;
     std::shared_ptr<arrow::RecordBatch> input_batch;
     RETURN_IF_ERROR(get_arrow_schema_from_block(input_block, &input_schema,
                                                 
TimezoneUtils::default_time_zone));
-    RETURN_IF_ERROR(convert_to_arrow_batch(input_block, input_schema, 
arrow::default_memory_pool(),
-                                           &input_batch, _timezone_obj));
+    if (child_column_idxs.empty()) {

Review Comment:
   Since this branch now carries `input_rows`, could we also reject a 
`ListArray` whose length does not match it after `_udtf_client->evaluate()`? 
`TableFunctionOperator` will still call `process_row()` once per child row, and 
`process_row()` indexes `array_nullmap_data[row_idx]` / `offsets_ptr[row_idx]`. 
If the Python side returns fewer rows than the child block, BE reads past the 
converted array metadata instead of failing cleanly. The scalar Python UDF path 
already guards this with `output_rows == input_rows`.



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