Skip to content

feat: Support map sort expression#3210

Draft
Shekharrajak wants to merge 7 commits intoapache:mainfrom
Shekharrajak:feature/support-map-sort-expression
Draft

feat: Support map sort expression#3210
Shekharrajak wants to merge 7 commits intoapache:mainfrom
Shekharrajak:feature/support-map-sort-expression

Conversation

@Shekharrajak
Copy link
Contributor

Which issue does this PR close?

Closes #3171

Rationale for this change

Implement native execution support for Apache Spark's map_sort expression, enabling efficient sorting of map entries by keys in ascending order within Comet's native execution engine.

What changes are included in this PR?

How are these changes tested?

  • spark/src/test/scala/org/apache/comet/CometMapExpressionSuite.scala

MapSort only exists in Spark 4.0+, not in 3.4/3.5
Adds MapSort serialization to Spark 4.0 version shim
Resolved conflicts:
- native/spark-expr/src/comet_scalar_funcs.rs: Combined spark_map_sort and SparkDateDiff imports
- spark-4.0/.../CometExprShim.scala: Combined MapSort and WidthBucket case statements
@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.90%. Comparing base (f09f8af) to head (a8d79fb).
⚠️ Report is 927 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3210      +/-   ##
============================================
- Coverage     56.12%   54.90%   -1.23%     
- Complexity      976     1432     +456     
============================================
  Files           119      175      +56     
  Lines         11743    16165    +4422     
  Branches       2251     2681     +430     
============================================
+ Hits           6591     8875    +2284     
- Misses         4012     6017    +2005     
- Partials       1140     1273     +133     

☔ 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.

@andygrove
Copy link
Member

Tests are failing:

2026-02-04T15:22:31.2961409Z - map_sort with integer keys *** FAILED *** (138 milliseconds)
2026-02-04T15:22:31.2962737Z   org.apache.spark.sql.AnalysisException: [UNRESOLVED_ROUTINE] Cannot resolve function `map_sort` on search path [`system`.`builtin`, `system`.`session`, `spark_catalog`.`default`].; line 1 pos 7
2026-02-04T15:22:31.2963943Z   at org.apache.spark.sql.errors.QueryCompilationErrors$.unreso

@Shekharrajak I'll move this to draft for now. Please mark as ready to review once the test failures ares resolved.

@andygrove andygrove marked this pull request as draft February 4, 2026 15:45
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.

[Feature] Support Spark expression: map_sort

3 participants