Skip to content

Commit

Permalink
[SPARK-46937][SQL][FOLLOWUP] Properly check registered function repla…
Browse files Browse the repository at this point in the history
…cement

### What changes were proposed in this pull request?

A followup of apache#44976 . `ConcurrentHashMap#put` has a different semantic than the scala map, and it returns null if the key is new. We should update the checking code accordingly.

### Why are the changes needed?

avoid wrong warning messages

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

manual

### Was this patch authored or co-authored using generative AI tooling?

no

Closes apache#46876 from cloud-fan/log.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
  • Loading branch information
cloud-fan authored and yaooqinn committed Jun 5, 2024
1 parent c4f720d commit 88b8dc2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ trait SimpleFunctionRegistryBase[T] extends FunctionRegistryBase[T] with Logging
builder: FunctionBuilder): Unit = {
val newFunction = (info, builder)
functionBuilders.put(name, newFunction) match {
case previousFunction if previousFunction != newFunction =>
case previousFunction if previousFunction != null =>
logWarning(log"The function ${MDC(FUNCTION_NAME, name)} replaced a " +
log"previously registered function.")
case _ =>
Expand Down

0 comments on commit 88b8dc2

Please sign in to comment.