Copilot commented on code in PR #1903:
URL: https://github.com/apache/auron/pull/1903#discussion_r2711074883
##########
native-engine/datafusion-ext-functions/src/lib.rs:
##########
@@ -39,51 +39,57 @@ pub fn create_auron_ext_function(
name: &str,
spark_partition_id: usize,
) -> Result<ScalarFunctionImplementation> {
+ macro_rules! cache {
+ ($func:path) => {{
+ static CELL: OnceLock<ScalarFunctionImplementation> =
OnceLock::new();
+ CELL.get_or_init(|| Arc::new($func)).clone()
+ }};
+ }
Review Comment:
The cache macro has a critical bug: all invocations share the same static
CELL variable. This means that once any function is cached in the first call,
all subsequent function lookups will return that same cached function,
regardless of which function was requested.
For example, if "Spark_NullIf" is called first, it will cache
spark_null_if::spark_null_if. Then when "Spark_NullIfZero" is called, it will
return the same spark_null_if::spark_null_if function instead of
spark_null_if::spark_null_if_zero.
To fix this, each invocation needs its own unique static variable. This can
be achieved by making the static variable name unique per function path, or by
using a different caching approach such as a global HashMap with function names
as keys.
--
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]