Skip to content

Conversation

@coderfender
Copy link
Contributor

Which issue does this PR close?

Closes #326

Rationale for this change

Comet surrently supports some basic string -> non int casts and this PR essentially extends on that to support all possible casts from string to non-int numeric (float, double and decimal) types

What changes are included in this PR?

Updates to cast logic to support exhaustive casts from string to numeric (non-int) types

How are these changes tested?

Unit tests and fuzz tests

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.39%. Comparing base (f09f8af) to head (c565a6d).
⚠️ Report is 730 commits behind head on main.

Files with missing lines Patch % Lines
...scala/org/apache/comet/expressions/CometCast.scala 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2835      +/-   ##
============================================
- Coverage     56.12%   54.39%   -1.74%     
- Complexity      976     1435     +459     
============================================
  Files           119      167      +48     
  Lines         11743    15185    +3442     
  Branches       2251     2523     +272     
============================================
+ Hits           6591     8260    +1669     
- Misses         4012     5709    +1697     
- Partials       1140     1216      +76     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

testAnsi = false)
test("cast StringType to DoubleType") {
Seq(true, false).foreach { v =>
castTest(specialValues.toDF("a"), DataTypes.FloatType, testAnsi = v)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
castTest(specialValues.toDF("a"), DataTypes.FloatType, testAnsi = v)
castTest(specialValues.toDF("a"), DataTypes.DoubleType, testAnsi = v)

) -> SparkResult<ArrayRef> {
let string_array = array
.as_any()
.downcast_ref::<StringArray>()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.downcast_ref::<StringArray>()
.downcast_ref::<GenericStringArray>()

To support LargeUtf8

@coderfender coderfender marked this pull request as draft December 2, 2025 16:00
@coderfender coderfender changed the title feat: Support string non int numeric types feat: Support casting string non int numeric types Dec 6, 2025
@coderfender coderfender force-pushed the support_string_non_int_numeric_types branch from e7a1144 to 79d0ea9 Compare December 7, 2025 19:36
@coderfender coderfender marked this pull request as ready for review December 7, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Spark-compatible CAST from String to Floating Point

3 participants