Skip to content

[AURON #2735] Align string cast trimming with Spark - #2736

Open
robreeves wants to merge 6 commits into
apache:masterfrom
robreeves:cast-string-integral-trim
Open

robreeves wants to merge 6 commits into
apache:masterfrom
robreeves:cast-string-integral-trim

Conversation

@robreeves

@robreeves robreeves commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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 in StringTrim, 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. So cast('\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:

  1. tinyint, smallint, int, bigint, and boolean use Spark's UTF8String check. A Spark version shim applies it to each byte: Character.isWhitespace for Spark 3.0 to 3.2, plus Character.isISOControl for Spark 3.3 and later.
  2. float, double, and decimal use Java's String.trim rule, 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 AuronQuerySuite tests for integral, boolean, and fractional targets that compare Auron with vanilla Spark through checkSparkAnswerAndOperator. They failed before the fix and pass after it on Spark 3.1 and 3.5. Updated the NativeConvertersSuite trim assertion.

Was this patch authored or co-authored using generative AI tooling?

  • Yes
  • No

Generated-by: GitHub Copilot CLI 1.0.65

ASF guidance: https://www.apache.org/legal/generative-tooling.html

Generated-by: GitHub Copilot CLI 1.0.65

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the spark label Nov 19, 2026
robreeves and others added 3 commits November 19, 2026 21:48
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>
@robreeves
robreeves marked this pull request as ready for review November 19, 2026 22:57
Copilot AI balanced review requested due to automatic review settings November 19, 2026 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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, and bigint casts.
  • 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>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 23:44
@robreeves robreeves changed the title [AURON #2735] Align string-to-integral cast trimming with Spark [AURON #2735] Align string cast trimming with Spark Nov 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are blocking the cast-trimming changes.

No open issues 🎉

Review effort: Balanced

Generated-by: GitHub Copilot CLI 1.0.65

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 00:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Spark-aligned cast-trimming changes.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cast from string to numeric and boolean types does not strip the same characters as Spark

2 participants