rctruta commented on code in PR #27674:
URL: https://github.com/apache/datafusion/pull/27674#discussion_r4724272951


##########
datafusion/sql/src/expr/function.rs:
##########
@@ -51,16 +51,42 @@ pub fn suggest_valid_function(
     find_closest_match(valid_funcs, input_function_name)
 }
 
-/// Find the closest matching string to the target string in the candidates 
list, using edit distance(case insensitive)
-/// Input `candidates` must not be empty otherwise an error is returned.
+/// Find the closest matching string to the target string in the candidates 
list,
+/// using edit distance (case insensitive).
+/// Returns `None` if `candidates` is empty or no candidate is close enough.
 fn find_closest_match(candidates: Vec<String>, target: &str) -> Option<String> 
{
     let target = target.to_lowercase();
-    candidates.into_iter().min_by_key(|candidate| {
-        datafusion_common::utils::datafusion_strsim::levenshtein(
-            &candidate.to_lowercase(),
-            &target,
-        )
-    })
+    let target_len = target.chars().count();
+    let mut cache = Vec::new();
+    let mut best_match: Option<(usize, usize, String, String)> = None;

Review Comment:
   Added the comment, thanks @alamb!"



-- 
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]

Reply via email to