shehab-ali commented on PR #21262:
URL: https://github.com/apache/datafusion/pull/21262#issuecomment-4268903339
Problem: When SessionState is rebuilt via
SessionStateBuilder::new_from_existing(), a user's UDF override can be silently
reverted, causing the wrong function to execute at query time.
Concrete example: a user registers postgres_to_char with alias "to_char" to
override the built-in to_char. Queries using to_char() correctly call the
custom implementation. But when any code path rebuilds the session state,
HashMap::into_values() emits both the custom UDF and the built-in (which
survived under its "date_format" alias key). build() re-registers both, and
last writer wins. If the built-in happens to register last, "to_char" now
points back to the built-in, and subsequent queries silently call the wrong
function. This happens nondeterministically depending on HashMap iteration
order.
What changed: the filter key.as_str() == udf.name() only keeps entries where
the HashMap key is the UDF's canonical name. This drops the built-in because
its canonical key ("to_char") was overwritten by the custom UDF; it only exists
under "date_format", which doesn't match its canonical name "to_char". So the
built-in is never passed to build(), and the custom UDF's override is preserved.
--
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]