What is the problem the feature request solves?
Note: This issue was generated with AI assistance. The specification details have been extracted from Spark documentation and may need verification.
Comet does not currently support the Spark days function, causing queries using this function to fall back to Spark's JVM execution instead of running natively on DataFusion.
The Days expression is a v2 partition transform that converts timestamp values to the number of days since a reference epoch. This transform is used for partitioning data by day buckets, allowing efficient querying of time-series data partitioned at the daily level.
Supporting this expression would allow more Spark workloads to benefit from Comet's native acceleration.
Describe the potential solution
Spark Specification
Syntax:
-- SQL syntax (when used in partition transforms)
PARTITIONED BY (days(timestamp_column))
// DataFrame API usage
import org.apache.spark.sql.catalyst.expressions.Days
Days(child = timestampColumn)
Arguments:
| Argument |
Type |
Description |
| child |
Expression |
The input expression that should evaluate to a timestamp or date value |
Return Type: IntegerType - Returns an integer representing the number of days since the epoch.
Supported Data Types:
- TimestampType
- DateType
- Any expression that can be implicitly cast to timestamp or date
Edge Cases:
- Null input values result in null output (standard null propagation)
- Timestamps before Unix epoch (1970-01-01) result in negative day numbers
- Leap years and daylight saving time transitions are handled according to the configured timezone
- Date boundary calculations respect the session timezone configuration
Examples:
-- Creating a table partitioned by days
CREATE TABLE events (
id BIGINT,
event_time TIMESTAMP,
data STRING
) PARTITIONED BY (days(event_time))
// DataFrame API usage in partition transforms
import org.apache.spark.sql.catalyst.expressions.Days
// Used internally when defining partition transforms
val dayTransform = Days(col("event_timestamp").expr)
Implementation Approach
See the Comet guide on adding new expressions for detailed instructions.
- Scala Serde: Add expression handler in
spark/src/main/scala/org/apache/comet/serde/
- Register: Add to appropriate map in
QueryPlanSerde.scala
- Protobuf: Add message type in
native/proto/src/proto/expr.proto if needed
- Rust: Implement in
native/spark-expr/src/ (check if DataFusion has built-in support first)
Additional context
Difficulty: Medium
Spark Expression Class: org.apache.spark.sql.catalyst.expressions.Days
Related:
Hours - Partition transform for hourly buckets
Months - Partition transform for monthly buckets
Years - Partition transform for yearly buckets
Bucket - Hash-based partition transform
PartitionTransformExpression - Base class for partition transforms
This issue was auto-generated from Spark reference documentation.
What is the problem the feature request solves?
Comet does not currently support the Spark
daysfunction, causing queries using this function to fall back to Spark's JVM execution instead of running natively on DataFusion.The
Daysexpression is a v2 partition transform that converts timestamp values to the number of days since a reference epoch. This transform is used for partitioning data by day buckets, allowing efficient querying of time-series data partitioned at the daily level.Supporting this expression would allow more Spark workloads to benefit from Comet's native acceleration.
Describe the potential solution
Spark Specification
Syntax:
-- SQL syntax (when used in partition transforms) PARTITIONED BY (days(timestamp_column))Arguments:
Return Type:
IntegerType- Returns an integer representing the number of days since the epoch.Supported Data Types:
Edge Cases:
Examples:
Implementation Approach
See the Comet guide on adding new expressions for detailed instructions.
spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scalanative/proto/src/proto/expr.protoif needednative/spark-expr/src/(check if DataFusion has built-in support first)Additional context
Difficulty: Medium
Spark Expression Class:
org.apache.spark.sql.catalyst.expressions.DaysRelated:
Hours- Partition transform for hourly bucketsMonths- Partition transform for monthly bucketsYears- Partition transform for yearly bucketsBucket- Hash-based partition transformPartitionTransformExpression- Base class for partition transformsThis issue was auto-generated from Spark reference documentation.