[AURON #2134] Implement native function of months_between#2149
Open
weimingdiit wants to merge 2 commits intoapache:masterfrom
Open
[AURON #2134] Implement native function of months_between#2149weimingdiit wants to merge 2 commits intoapache:masterfrom
weimingdiit wants to merge 2 commits intoapache:masterfrom
Conversation
Spark `months_between(...)` was not supported in Auron’s native execution path, so queries using it fell back instead of being planned and executed natively. This change adds native support through the extension-function path and keeps the behavior aligned with Spark semantics for `DATE` and `TIMESTAMP` inputs, including `roundOff` handling and session time zone aware calculations. This PR: - adds Spark `MonthsBetween` expression conversion in `NativeConverters` - adds `buildMonthsBetweenExt` to pass `date1`, `date2`, `roundOff`, and session time zone to the native function - registers `Spark_MonthsBetween` in `datafusion-ext-functions` - implements `spark_months_between` in `spark_dates.rs` - handles Spark-compatible same-day and last-day-of-month cases, fractional month calculation, rounding, and null propagation - adds regression coverage in `AuronFunctionSuite` - adds Rust unit tests for core `months_between` semantics --------- Signed-off-by: weimingdiit <weimingdiit@gmail.com>
16 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds native execution support for Spark months_between(...) via Auron’s extension-function path so queries can be planned/executed natively instead of falling back.
Changes:
- Convert Spark
MonthsBetweenexpressions inNativeConvertersand build an ext-function call includingroundOffand (when needed) session time zone. - Register and implement
Spark_MonthsBetweenin the native DataFusion ext-functions crate with Spark-compatible edge-case handling. - Add Scala regression coverage and Rust unit tests for
months_betweensemantics.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala | Adds Spark MonthsBetween conversion and builds the ext-function call arguments (incl. roundOff + tz). |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala | Adds an end-to-end Spark regression test exercising months_between native execution. |
| native-engine/datafusion-ext-functions/src/spark_dates.rs | Implements spark_months_between and adds unit tests for core semantics. |
| native-engine/datafusion-ext-functions/src/lib.rs | Registers Spark_MonthsBetween in the ext-function factory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
spark-extension/src/main/scala/org/apache/spark/sql/auron/NativeConverters.scala
Outdated
Show resolved
Hide resolved
Signed-off-by: weimingdiit <weimingdiit@gmail.com>
yew1eb
approved these changes
Apr 3, 2026
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 #2134
Rationale for this change
Spark
months_between(...)was not supported in Auron’s native execution path, so queries using it fell back instead of being planned and executed natively.This change adds native support through the extension-function path and keeps the behavior aligned with Spark semantics for
DATEandTIMESTAMPinputs, includingroundOffhandling and session time zone aware calculations.What changes are included in this PR?
This PR:
MonthsBetweenexpression conversion inNativeConvertersbuildMonthsBetweenExtto passdate1,date2,roundOff, and session time zone to the native functionSpark_MonthsBetweenindatafusion-ext-functionsspark_months_betweeninspark_dates.rsAuronFunctionSuitemonths_betweensemanticsAre there any user-facing changes?
NO.
How was this patch tested?
CI.