Repository navigation
Conversation
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The Spark-compatible string-to-integral trimming update has no active review issues.
No open issues 🎉
What changed in this PR
Updates Auron’s native string-to-integral casts to match Spark’s whitespace and control-character trimming when spark.auron.cast.trimString=true, addressing #2735.
Changes:
- Adds Spark-version-specific trimming for
tinyint,smallint,int, andbigintcasts. - Preserves existing trimming for other numeric and boolean casts.
- Adds Spark comparison coverage and updates converter assertions.
| File | Description |
|---|---|
| spark-extension/src/main/scala/org/apache/spark/sql/auron/Shims.scala | Declares the integral-cast trimming predicate. |
| spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala | Applies explicit trim characters to string-to-integral casts. |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/NativeConvertersSuite.scala | Updates assertions for trim argument counts. |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronQuerySuite.scala | Adds whitespace and control-character cast comparisons against Spark. |
| spark-extension-shims-spark/src/main/scala/org/apache/spark/sql/auron/ShimsImpl.scala | Implements version-specific whitespace and control-character checks. |
Review effort: Balanced
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generated-by: GitHub Copilot CLI 1.0.65 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 #2735
Rationale for this change
With
spark.auron.cast.trimString=true, Auron wraps string-to-number and string-to-boolean casts inStringTrim, which removes only spaces. Spark strips more before parsing: tabs, newlines, other whitespace, and, for integral and boolean casts since Spark 3.3.3/3.4.1, ISO control characters. Socast('\t42' as int)returns 42 in Spark and null in Auron.What changes are included in this PR?
The trim now removes the same characters Spark strips for each target type:
tinyint,smallint,int,bigint, andbooleanuse Spark'sUTF8Stringcheck. A Spark version shim applies it to each byte:Character.isWhitespacefor Spark 3.0 to 3.2, plusCharacter.isISOControlfor Spark 3.3 and later.float,double, anddecimaluse Java'sString.trimrule, which strips every character up to U+0020 on all Spark versions.Are there any user-facing changes?
With
spark.auron.cast.trimString=true, string-to-numeric and string-to-boolean casts now match Spark for values padded with whitespace or control characters.How was this patch tested?
Added
AuronQuerySuitetests for integral, boolean, and fractional targets that compare Auron with vanilla Spark throughcheckSparkAnswerAndOperator. They failed before the fix and pass after it on Spark 3.1 and 3.5. Updated theNativeConvertersSuitetrim assertion.Was this patch authored or co-authored using generative AI tooling?
Generated-by: GitHub Copilot CLI 1.0.65
ASF guidance: https://www.apache.org/legal/generative-tooling.html