andygrove opened a new issue, #3133:
URL: https://github.com/apache/datafusion-comet/issues/3133

   ## 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 `current_time_zone` function, 
causing queries using this function to fall back to Spark's JVM execution 
instead of running natively on DataFusion.
   
   The `CurrentTimeZone` expression returns the current session time zone as a 
string. This is a non-deterministic expression that retrieves the time zone 
setting for the current Spark session without requiring any input parameters.
   
   Supporting this expression would allow more Spark workloads to benefit from 
Comet's native acceleration.
   
   ## Describe the potential solution
   
   ### Spark Specification
   
   **Syntax:**
   ```sql
   SELECT current_timezone();
   ```
   
   ```scala
   // DataFrame API
   import org.apache.spark.sql.functions._
   df.select(expr("current_timezone()"))
   ```
   
   **Arguments:**
   | Argument | Type | Description |
   |----------|------|-------------|
   | None | N/A | This expression takes no arguments |
   
   **Return Type:** `StringType` - Returns the time zone identifier as a string 
(e.g., "Asia/Shanghai", "UTC").
   
   **Supported Data Types:**
   This expression does not accept input data types as it is a leaf expression 
with no parameters.
   
   **Edge Cases:**
   - Never returns null values (`nullable = false`)
   - Always returns a valid time zone string based on session configuration
   - Behavior is consistent within a single session but may vary across 
different sessions
   - No overflow or underflow conditions as it returns configuration data
   
   **Examples:**
   ```sql
   -- Get current session timezone
   SELECT current_timezone();
   -- Result: Asia/Shanghai
   
   -- Use in a query with other datetime functions
   SELECT current_timestamp(), current_timezone();
   ```
   
   ```scala
   // DataFrame API usage
   import org.apache.spark.sql.functions._
   
   // Add timezone column to existing DataFrame
   df.withColumn("session_tz", expr("current_timezone()"))
   
   // Select timezone with other columns
   df.select($"id", expr("current_timezone()").as("timezone"))
   ```
   
   ### Implementation Approach
   
   See the [Comet guide on adding new 
expressions](https://datafusion.apache.org/comet/contributor-guide/adding_a_new_expression.html)
 for detailed instructions.
   
   1. **Scala Serde**: Add expression handler in 
`spark/src/main/scala/org/apache/comet/serde/`
   2. **Register**: Add to appropriate map in `QueryPlanSerde.scala`
   3. **Protobuf**: Add message type in `native/proto/src/proto/expr.proto` if 
needed
   4. **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.CurrentTimeZone`
   
   **Related:**
   - `current_timestamp()` - Returns current timestamp in session timezone
   - `current_date()` - Returns current date in session timezone
   - Timezone conversion functions for working with different time zones
   
   ---
   *This issue was auto-generated from Spark reference documentation.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to