github-actions[bot] commented on code in PR #62249:
URL: https://github.com/apache/doris/pull/62249#discussion_r3165365309
##########
be/src/exprs/function/function_python_udf.cpp:
##########
@@ -141,8 +163,13 @@ Status PythonFunctionCall::execute_impl(FunctionContext*
context, Block& block,
std::shared_ptr<arrow::RecordBatch> input_batch;
std::shared_ptr<arrow::RecordBatch> output_batch;
cctz::time_zone _timezone_obj; // default UTC
- RETURN_IF_ERROR(convert_to_arrow_batch(input_block, schema,
arrow::default_memory_pool(),
- &input_batch, _timezone_obj));
+ if (arguments.empty()) {
+ input_batch = arrow::RecordBatch::Make(schema, input_rows,
+
std::vector<std::shared_ptr<arrow::Array>> {});
Review Comment:
This adds zero-argument Python UDF execution, but BE still has no Python
deterministic metadata. `VectorizedFnCall::is_constant()` only special-cases
zero-arg `JAVA_UDF`, so a zero-arg Python UDF declared `deterministic="false"`
can still be folded/evaluated once for a fragment and reused for all rows. A
function like `return random.random()` or `return time.time()` would return one
repeated value in `SELECT py_rand() FROM t`, despite the new FE/Nereids
deterministic flag. Please pass/enforce the deterministic flag in the BE
function constantness path, or at least disable constant treatment for zero-arg
Python UDFs as Java UDFs do.
##########
be/src/agent/task_worker_pool.cpp:
##########
@@ -2511,6 +2512,7 @@ void clean_udf_cache_callback(const TAgentTaskRequest&
req) {
if (clean_req.__isset.function_id && clean_req.function_id > 0) {
UserFunctionCache::instance()->drop_function_cache(clean_req.function_id);
+
PythonServerManager::instance().clear_udaf_state_cache(clean_req.function_id);
}
Review Comment:
`clear_udaf_state_cache()` is a `void` wrapper that uses `THROW_IF_ERROR`
around a broadcast to Python processes. This callback does not catch
exceptions, so a normal race where a Python process dies after `is_alive()` but
before `FlightClient::Connect()`/`DoAction()` can make the clean-cache agent
task throw out of the worker instead of just logging the failed cleanup. The
neighboring module-cache cleanup already returns `Status` and logs failures;
please make the UDAF cleanup follow that pattern instead of throwing from this
task callback.
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/FunctionToSqlConverter.java:
##########
@@ -75,6 +75,13 @@ public static String toSql(ScalarFunction fn, boolean
ifNotExists) {
.append("\"" + (fn.getLocation() == null ? "" :
fn.getLocation().toString()) + "\"");
boolean isReturnNull = fn.getNullableMode() ==
NullableMode.ALWAYS_NULLABLE;
sb.append(",\n \"ALWAYS_NULLABLE\"=").append("\"" + isReturnNull
+ "\"");
+ sb.append(",\n \"DETERMINISTIC\"=").append("\"" +
fn.isDeterministic() + "\"");
+ } else if (fn.getBinaryType() == Function.BinaryType.PYTHON_UDF) {
+ sb.append(",\n \"FILE\"=")
+ .append("\"" + (fn.getLocation() == null ? "" :
fn.getLocation().toString()) + "\"");
+ boolean isReturnNull = fn.getNullableMode() ==
NullableMode.ALWAYS_NULLABLE;
+ sb.append(",\n \"ALWAYS_NULLABLE\"=").append("\"" + isReturnNull
+ "\"");
+ sb.append(",\n \"DETERMINISTIC\"=").append("\"" +
fn.isDeterministic() + "\"");
} else {
Review Comment:
The Python branch still does not emit all properties required to recreate
the function. `CreateFunctionCommand` requires `runtime_version` for every
`PYTHON_UDF`, and inline Python functions also need the persisted
`functionCode` rendered as `AS $$...$$`; with this output, `SHOW CREATE
FUNCTION` followed by executing the shown SQL fails with `Python runtime
version is not set` or recreates a module function without the inline body. For
Python UDTFs, the same scalar path also prints `CREATE FUNCTION ... RETURNS
<item type>` instead of `CREATE TABLES FUNCTION ... RETURNS ARRAY<...>`, losing
table-function semantics. Please make the generated SQL round-trip for Python
UDF/UDAF/UDTF before adding only the deterministic property.
--
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]