From 801ad002bceca887db9d7632f1658a68c4b1caf7 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Mon, 20 May 2024 14:30:00 +0800 Subject: [PATCH] return error when finding multiple udf impls Signed-off-by: Runji Wang --- src/expr/core/src/sig/udf.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/expr/core/src/sig/udf.rs b/src/expr/core/src/sig/udf.rs index 5c75a188c83bc..efc3c42b87614 100644 --- a/src/expr/core/src/sig/udf.rs +++ b/src/expr/core/src/sig/udf.rs @@ -18,7 +18,7 @@ //! //! See expr/impl/src/udf for the implementations. -use anyhow::{Context, Result}; +use anyhow::{bail, Context, Result}; use arrow_array::RecordBatch; use futures::stream::BoxStream; use risingwave_common::types::DataType; @@ -40,12 +40,16 @@ pub fn find_udf_impl( runtime: Option<&str>, link: Option<&str>, ) -> Result<&'static UdfImplDescriptor> { - UDF_IMPLS + let mut impls = UDF_IMPLS .iter() - .find(|desc| (desc.match_fn)(language, runtime, link)) - .context( - "language not found.\nHINT: UDF feature flag may not be enabled during compilation", - ) + .filter(|desc| (desc.match_fn)(language, runtime, link)); + let impl_ = impls.next().context( + "language not found.\nHINT: UDF feature flag may not be enabled during compilation", + )?; + if impls.next().is_some() { + bail!("multiple UDF implementations found for language: {language}"); + } + Ok(impl_) } /// UDF implementation descriptor.