[AURON #2128] Implement native function of dayofweek#2129
Merged
slfan1989 merged 1 commit intoapache:masterfrom Mar 31, 2026
Merged
[AURON #2128] Implement native function of dayofweek#2129slfan1989 merged 1 commit intoapache:masterfrom
slfan1989 merged 1 commit intoapache:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds native support for Spark-compatible dayofweek() by wiring a new Spark expression conversion to a native DataFusion extension function and validating results via unit/integration tests.
Changes:
- Added
DayOfWeek→Spark_DayOfWeektranslation in SparkNativeConverters. - Implemented native
spark_dayofweek()inspark_dates.rsand registered it in the ext-function factory. - Added a Spark-side test case validating
dayofweek()output for a DATE column and a string literal.
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 | Routes Spark’s DayOfWeek expression to the native ext function Spark_DayOfWeek. |
| spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala | Adds a Spark integration test for dayofweek() on a DATE column and a string literal. |
| native-engine/datafusion-ext-functions/src/spark_dates.rs | Implements spark_dayofweek() (Date32-based) and adds a Rust unit test. |
| native-engine/datafusion-ext-functions/src/lib.rs | Registers Spark_DayOfWeek in the native extension function factory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
spark-extension-shims-spark/src/test/scala/org/apache/auron/AuronFunctionSuite.scala
Show resolved
Hide resolved
Signed-off-by: weimingdiit <weimingdiit@gmail.com>
1b313f9 to
45ada3d
Compare
slfan1989
approved these changes
Mar 31, 2026
Contributor
|
@weimingdiit Thanks for the contribution! Merged into master. |
Contributor
Author
|
15 tasks
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 ##2128
Rationale for this change
To achieve full compatibility with Spark’s date functions, we should implement
dayofweek()with the following characteristics:Expected behavior
Function name:
dayofweek(expr)Return value:
Sunday = 1, Monday = 2, ..., Saturday = 7Example:
dayofweek('2009-07-30')→5Supports:
DATE,TIMESTAMP, and compatible string/date inputs consistent with existing date extraction functionsNull-safe: should return
NULLif input isNULLArray and scalar inputs: consistent with current date extraction function implementations
What changes are included in this PR?
This PR adds native support for the
dayofweek()function with Spark-compatible semantics.The following changes are included:
spark_dayofweek()in the expression layer.DayOfWeekexpression support inNativeConvertersfor proper Spark → native translation.Are there any user-facing changes?
No.
How was this patch tested?
CI.