Skip to content

[EPIC] Spark-compatible cast / try_cast operations #286

Closed

Description

@andygrove

What is the problem the feature request solves?

Comet currently delegates to DataFusion for many cast operations, and the behavior is not guaranteed to match Spark. This epic is to track fully implementing Spark-compatible cast and try_cast operations in Comet, with support for ANSI mode.

For each item in this list to be considered complete, we should have scala tests demonstrating that cast and try_cast produce the same results as Spark, both with ANSI mode enabled and disabled, using fuzz testing to find edge cases. We can update this list with links to issues as we make progress.

For cast operations that we cannot easily support with full compatibility, we should either fall back to Spark or provide a configuration that the user can enable to allow the operation to run in Comet. We should also provide documentation explaining any differences in behavior compared to Spark.

In addition to the above tasks, we also need to do the following:

Activity

  1. added
    enhancement
    on Apr 18, 2024
  2. added
    help wanted
    on Apr 18, 2024
  3. edmondop commented on Apr 19, 2024

    @edmondop
    Contributor

    @andygrove do we have already a framework for fuzz testing in Scala (i.e. ScalaCheck?) Should anyone wait until you are done with the first ones so you establish a pattern?

  4. andygrove commented on Apr 19, 2024

    @andygrove
    MemberAuthor

    @andygrove do we have already a framework for fuzz testing in Scala (i.e. ScalaCheck?) Should anyone wait until you are done with the first ones so you establish a pattern?

    There is a CometCastSuite and I am working on a PR right now to improve this and I am also implementing cast string to boolean (an easy one) so that there is an example for others to learn from. I should have a draft PR up on Monday.

  5. andygrove commented on Apr 22, 2024

    @andygrove
    MemberAuthor

    I am now working on cast string -> integral types. I will have a PR up later this week.

  6. edmondop commented on Apr 28, 2024

    @edmondop
    Contributor

    @andygrove can I take care of this " Implement a mechanism where we can selectively fall back to Spark for specific cast operations" ? I was looking at the top of the list, but everything was quickly taken

  7. andygrove commented on Apr 29, 2024

    @andygrove
    MemberAuthor

    @edmondop feel free to pick up other items on the list that don't have issues yet (I will start filing more!)

    I added an example of falling back top Spark for cast string to timestamp in #337 so we do have an approach. I will update that item in this epic.

  8. andygrove commented on Apr 29, 2024

    @andygrove
    MemberAuthor

    @edmondop also just added #350

  9. coderfender commented on Sep 29, 2025

    @coderfender
    Contributor

    What is the problem the feature request solves?

    Comet currently delegates to DataFusion for many cast operations, and the behavior is not guaranteed to match Spark. This epic is to track fully implementing Spark-compatible cast and try_cast operations in Comet, with support for ANSI mode.

    For each item in this list to be considered complete, we should have scala tests demonstrating that cast and try_cast produce the same results as Spark, both with ANSI mode enabled and disabled, using fuzz testing to find edge cases. We can update this list with links to issues as we make progress.

    For cast operations that we cannot easily support with full compatibility, we should either fall back to Spark or provide a configuration that the user can enable to allow the operation to run in Comet. We should also provide documentation explaining any differences in behavior compared to Spark.

    In addition to the above tasks, we also need to do the following:

    Raised issue : #2489 to track Decimal to Boolean cast op and integer to decimal cast op #2472

  10. coderfender commented on Oct 12, 2025

    @coderfender
    Contributor

    Raised : #2490 for Decimal -> Boolean cast native support

  11. coderfender commented on Dec 8, 2025

    @coderfender
    Contributor

    Raised : #2835 for full String -> float/Double casts

  12. coderfender commented on Dec 17, 2025

    @coderfender
    Contributor

    Raised #2926 to track String -> Decimal Type casting

  13. andygrove commented on Jan 30, 2026

    @andygrove
    MemberAuthor

    @coderfender do you think we can close this epic now? Do you we need to create any additional issues for remaining work?

  14. coderfender commented on Jan 30, 2026

    @coderfender
    Contributor

    @andygrove I believe we can close / update this EPIC given that most of the expressions are supported and we also now have documentation with cast support at different eval modes. We might however want to create new epic for temporal casts which @parthchandra might be working on

  15. attilapiros commented on Jan 31, 2026

    @attilapiros

    For your awareness, this Spark PR was recently submitted: apache/spark#53458
    and this will affect how an invalid UTF-8 from binary to string will be casted.

  16. coderfender commented on Feb 5, 2026

    @coderfender
    Contributor

    Issue to to cast from date to timestamp : #3400
    PR : #3383

  17. boudica-dev-eng commented on Feb 5, 2026

    @boudica-dev-eng

    I haven't found an issue for Long -> Timestamp. Is this planned?

  18. coderfender commented on Feb 6, 2026

    @coderfender
    Contributor

    whole numbers to binary and bool to decimal : #3083

  19. coderfender commented on Mar 9, 2026

    @coderfender
    Contributor

    numeric (non int) to timestamp : #3560

  20. andygrove commented on Apr 24, 2026

    @andygrove
    MemberAuthor

    All items in this epic are now completed 🎉 so let's close this and just file individual issues for any are casts that need implementing.

  21. coderfender commented on Apr 24, 2026

    @coderfender
    Contributor

    This is great news @andygrove !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wantedspark 4.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions