Myx778 commented on code in PR #4105: URL: https://github.com/apache/datafusion-comet/pull/4105#discussion_r3193674055
########## spark/src/test/resources/sql-tests/expressions/string/levenshtein_threshold.sql: ########## @@ -0,0 +1,40 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- MinSparkVersion: 3.5 + +statement +CREATE TABLE test_levenshtein(s1 string, s2 string) USING parquet + +statement +INSERT INTO test_levenshtein VALUES ('kitten', 'sitting'), ('frog', 'fog'), ('abc', 'abc'), ('', 'hello'), ('hello', ''), ('', ''), (NULL, 'test'), ('hello', NULL), (NULL, NULL) + +-- three argument version with threshold +query +SELECT levenshtein('kitten', 'sitting', 2), levenshtein('kitten', 'sitting', 3), levenshtein('kitten', 'sitting', 4) Review Comment: Done! The implementation now supports threshold as both scalar and column. **Changes:** - Refactored `spark_levenshtein` to use `into_array()` which handles both `ColumnarValue::Scalar` and `ColumnarValue::Array` uniformly - Per-row NULL threshold → NULL result for that row - Added Scala integration tests (`levenshtein with threshold as column` + null/negative cases) - Added SQL file tests with threshold column **Rust unit test results (all 8 passing):** ``` running 8 tests test string_funcs::levenshtein::tests::test_levenshtein_basic ... ok test string_funcs::levenshtein::tests::test_levenshtein_unicode ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_nulls ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_null_threshold ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_with_threshold ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_threshold_as_array ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_threshold_array_with_nulls ... ok test string_funcs::levenshtein::tests::test_spark_levenshtein_threshold_negative ... ok test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 341 filtered out ``` -- 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]
