Wire PPL string scalar functions with analytics-backend-datafusion - #21543
Conversation
PR Reviewer Guide 🔍(Review updated until commit a07f9b5)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to a07f9b5 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 3a69307
Suggestions up to commit f0c0566
Suggestions up to commit 88ca200
|
|
❌ Gradle check result for 88ca200: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit f0c0566 |
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 7abb1d1.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
|
Persistent review updated to latest commit 3a69307 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21543 +/- ##
============================================
+ Coverage 73.45% 73.53% +0.08%
- Complexity 74591 74626 +35
============================================
Files 5980 5980
Lines 338779 338779
Branches 48848 48848
============================================
+ Hits 248849 249124 +275
+ Misses 70079 69818 -261
+ Partials 19851 19837 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
pls add a test in our qa pkg - similar tests https://github.com/opensearch-project/OpenSearch/tree/main/sandbox/qa/analytics-engine-rest/src/test/java/org/opensearch/analytics/qa |
Signed-off-by: Tanik Pansuriya <panbhai@amazon.com>
|
Persistent review updated to latest commit a07f9b5 |
Description
Wires PPL string scalar functions through the analytics-backend-datafusion plugin, enabling native DataFusion execution for string operations.
Functions added
ascii(str)concat(str1, ..., strN)concat_ws(sep, str1, str2)left(str, n)length(str)char_lengthlocate(substr, str)lower(str)ltrim(str)position(substr, str)reverse(str)right(str, n)rtrim(str)strcmp(str1, str2)substr(str, start[, len])substringtostring(value[, format])tonumber(string[, base])trim(str)btrim)upper(str)Key changes
ToStringFunctionAdapter— Routes 1-arg calls throughCAST(x AS VARCHAR), boolean values through an explicitCASE WHEN ... THEN 'TRUE' ... THEN 'FALSE' END(DataFusion's CAST produces lowercase), and 2-arg format calls (hex/binary/commas/duration/duration_millis) through thetostringRust UDF.ToNumberFunctionAdapter— 1-arg calls use SAFE_CAST to DOUBLE (substrait's null-on-failure cast, which DataFusion maps totry_cast) so unparseable values liketonumber('abc')return NULL instead of hard-erroring in thesimplify_expressionsoptimizer. Handles both fractional ('4598.678') and integer input. 2-arg calls route through thetonumberRust UDF for base-N integer parsing (i64::from_str_radix); the UDF returns NULL on parse failure.StrcmpFunctionAdapter— The PPL frontend reversesstrcmparguments; the adapter swaps them back. The comparison itself is decomposed into a SIMD-vectorizedCASE WHEN lhs IS NULL OR rhs IS NULL THEN NULL WHEN lhs < rhs THEN -1 WHEN lhs = rhs THEN 0 ELSE 1 ENDso DataFusion evaluates it through its native arrow-rs compare kernels — no Rust UDF needed.PositionAdapter— PPL'sPOSITION(substr IN str)andlocate(substr, str[, start])has reversed argument order vs DataFusion'sstrpos(str, substr)and supports an optionalstartposition thatstrposdoesn't. The adapter swaps arguments for the 2-arg form; for the 3-arg form it decomposes tosubstring(str, start) + strpos(substring(str, start), substr) - 1, preserving 1-based semantics.Related Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.