[AURON #2279] Implement native Levenshtein with threshold support for Spark 4.0+#2280
Open
lyne7-sc wants to merge 7 commits into
Open
[AURON #2279] Implement native Levenshtein with threshold support for Spark 4.0+#2280lyne7-sc wants to merge 7 commits into
lyne7-sc wants to merge 7 commits into
Conversation
…spark_levenshtein # Conflicts: # native-engine/auron-planner/src/planner.rs
| Ok(ColumnarValue::Array(Arc::new(splitted_builder.finish()))) | ||
| } | ||
|
|
||
| pub fn spark_levenshtein(args: &[ColumnarValue]) -> Result<ColumnarValue> { |
Contributor
There was a problem hiding this comment.
Correct me if I'm wrong but, in spark_levenshtein, a null threshold is coerced to Some(0), which then returns -1 for any non-zero distance and 0 for equal strings:
Some(ColumnarValue::Scalar(scalar)) if scalar.is_null() => Some(0),
...
Some(array) if array.data_type() == &DataType::Null => Some(0),
Some(_) => thresholds.map(|array| if array.is_valid(i) { array.value(i) } else { 0 }),
I think that doesn't match Spark. In Spark, Levenshtein.eval only null-checks left/right..a null threshold at runtime causes an NPE during v.asInstanceOf[Int]. The defensible options are (a) propagate null when threshold is null, or (b) mirror Spark and error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #2279
Rationale for this change
Spark 4+ introduced an optional
thresholdparameter forLevenshtein. The previous native implementation delegated to DataFusion's built-inlevenshtein()which only supports 2 arguments.What changes are included in this PR?
spark_levenshteinnative function that supports both 2-arg and 3-arg (with threshold) formsNativeConverters.scalato routeLevenshteinthroughbuildExtScalarFunction("Spark_Levenshtein")instead of the oldbuildScalarFunctionpath.exclude("string Levenshtein distance")from Spark 4.0 and 4.1 test settingsAre there any user-facing changes?
Yes. The native
levenshtein()function now supports the optional thirdthresholdparameter.How was this patch tested?
AuronStringFunctionsSuiteandAuronFunctionSuiteincluding "test function Levenshtein"