[AURON #2335] Support more literal patterns in native split#2336
Open
weimingdiit wants to merge 1 commit into
Open
[AURON #2335] Support more literal patterns in native split#2336weimingdiit wants to merge 1 commit into
weimingdiit wants to merge 1 commit into
Conversation
Signed-off-by: weimingdiit <weimingdiit@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands native conversion coverage for Spark split expressions when the pattern can be safely treated as a literal string (including escaped regex metacharacters like \\+), reducing unnecessary fallbacks while still rejecting patterns requiring true regex semantics.
Changes:
- Replace the hard-coded
splitpattern allowlist with a small literal-pattern parser inShimsImpl. - Route eligible
StringSplitexpressions to nativeSpark_StringSplitusing the parsed literal separator. - Add SQL test coverage for additional literal separators (
/,\\+,::).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spark-extension-shims-spark/src/main/scala/org/apache/spark/sql/auron/ShimsImpl.scala | Adds literal-pattern parsing and expands native conversion eligibility for StringSplit. |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala | Adds a test exercising the newly supported literal split patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+192
to
+199
| test("split function with literal regex patterns") { | ||
| withTable("t1") { | ||
| sql("create table t1(c1 string, c2 string, c3 string) using parquet") | ||
| sql("insert into t1 values('a/b/c', 'a+b+c', 'a::b::c'), (null, null, null)") | ||
| checkSparkAnswerAndOperator( | ||
| "select split(c1, '/'), split(c2, '\\\\+'), split(c3, '::') from t1") | ||
| } | ||
| } |
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 #2335
Rationale for this change
Spark
splitconversion currently supports only a fixed set of literal patterns. This causes safe literal patterns such as/,\\+, and::to fall back even though nativeSpark_StringSplitalready splits by literal string pattern.This PR expands native coverage for common non-regex split patterns without adding full regex support.
What changes are included in this PR?
This PR updates Spark
StringSplitconversion inShimsImplto recognize patterns that can be safely treated as literal strings.The new logic supports:
Patterns requiring regex semantics continue to fall back.
This PR also adds SQL coverage in
AuronFunctionSuitefor:split(c1, '/')split(c2, '\\+')split(c3, '::')Are there any user-facing changes?
Yes. More Spark
splitexpressions with literal patterns can now be executed natively instead of falling back to Spark.There is no behavior change for regex patterns that are not safe to treat as literals.
How was this patch tested?
UT.