You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "0lai0 (via GitHub)" <gi...@apache.org> on 2026/03/27 07:15:03 UTC

[PR] feat: Support Spark expression hours [datafusion-comet]

0lai0 opened a new pull request, #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #3125 
   
   ## Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   Comet previously did not support the Spark `hours` expression (a V2 partition transform). 
   Queries using the `hours` function for partitioning would fall back to Spark's JVM execution instead of running natively on DataFusion. By adding native support for this expression, we allow more Spark workloads (especially those partitioned by hourly intervals) to benefit from Comet's native acceleration.
   
   ## What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   This change adds end-to-end native support for the `hours` partition transform. Since `Hours` is a `PartitionTransformExpression` (and not a `TimeZoneAwareExpression`), the timezone is injected from the session configuration during the planning phase. 
   The native implementation uses Arrow's `unary` and `try_unary` kernels for efficient vectorized computation, and correctly handles pre-epoch (negative) timestamps using Euclidean floor division (`div_euclid`). It distinctly handles both `TimestampType` (applies timezone offsets) and `TimestampNTZType` (direct wall-clock computation).
   
   - `expr.proto`: Added `HoursTransform` message definition to pass the child expression and session timezone.
   -  `datetime.scala`: Added `CometHours` serde handler to intercept the Spark `Hours` expression and read the timezone from `SQLConf`.
   - `QueryPlanSerde.scala`: Registered the `CometHours` handler in the temporal expressions map.
   - `hours.rs`: Added `SparkHoursTransform` UDF using efficient Arrow kernels.
   - `temporal.rs` & `expression_registry.rs`: Registered the native Builder for the new expression.
   
   ## How are these changes tested?
   
   Added comprehensive evaluation in both Rust and Scala:
   1. Rust Unit Tests : Added unit tests in `hours.rs` covering:
      - Positive/negative (pre-epoch) epoch handling
      - Epoch boundary (zero)
      - Timezone offset handling 
      - Null propagation
      - Proper isolation of `TimestampNTZType` (ensuring it ignores timezone offsets)
      ```bash
      cargo test -p datafusion-comet-spark-expr -- datetime_funcs::hours
   2. Scala Integration Tests: Evaluated end-to-end execution in CometTemporalExpressionSuite.
      ```bash
      ./mvnw test -pl spark -Dsuites='org.apache.comet.CometTemporalExpressionSuite'
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3063449733


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,274 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! Both `TimestampType` and `TimestampNTZType` are computationally identical. They
+//! extract the absolute hours since the epoch by directly dividing the microsecond
+//! value by the number of microseconds in an hour, ignoring session timezone offsets.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+}
+
+impl SparkHoursTransform {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);

Review Comment:
   Fixed. Moved the cast inside the `DataType::Timestamp(Microsecond,_)` to prevent panics on unsupported types.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3055988151


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,299 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! - For `Timestamp(Microsecond, Some(tz))`: applies timezone offset before computing.
+//! - For `Timestamp(Microsecond, None)` (NTZ): uses raw microseconds directly.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use arrow::temporal_conversions::as_datetime;
+use chrono::{Offset, TimeZone};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+use crate::timezone::Tz;
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+    timezone: String,
+}
+
+impl SparkHoursTransform {
+    pub fn new(timezone: String) -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+            timezone,
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, Some(_)) => {
+                        let tz: Tz = self.timezone.parse().map_err(|e| {
+                            DataFusionError::Execution(format!(
+                                "Failed to parse timezone '{}': {}",
+                                self.timezone, e
+                            ))
+                        })?;
+                        arrow::compute::kernels::arity::try_unary(ts_array, |micros| {
+                            let dt = as_datetime::<TimestampMicrosecondType>(micros).ok_or_else(
+                                || {
+                                    DataFusionError::Execution(format!(
+                                        "Cannot convert {micros} to datetime"
+                                    ))
+                                },
+                            )?;
+                            let offset_secs =
+                                tz.offset_from_utc_datetime(&dt).fix().local_minus_utc() as i64;
+                            let local_micros = micros + offset_secs * 1_000_000;

Review Comment:
   PR updated. Thanks!



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3047127823


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,299 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! - For `Timestamp(Microsecond, Some(tz))`: applies timezone offset before computing.
+//! - For `Timestamp(Microsecond, None)` (NTZ): uses raw microseconds directly.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use arrow::temporal_conversions::as_datetime;
+use chrono::{Offset, TimeZone};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+use crate::timezone::Tz;
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+    timezone: String,
+}
+
+impl SparkHoursTransform {
+    pub fn new(timezone: String) -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+            timezone,
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, Some(_)) => {
+                        let tz: Tz = self.timezone.parse().map_err(|e| {
+                            DataFusionError::Execution(format!(
+                                "Failed to parse timezone '{}': {}",
+                                self.timezone, e
+                            ))
+                        })?;
+                        arrow::compute::kernels::arity::try_unary(ts_array, |micros| {
+                            let dt = as_datetime::<TimestampMicrosecondType>(micros).ok_or_else(
+                                || {
+                                    DataFusionError::Execution(format!(
+                                        "Cannot convert {micros} to datetime"
+                                    ))
+                                },
+                            )?;
+                            let offset_secs =
+                                tz.offset_from_utc_datetime(&dt).fix().local_minus_utc() as i64;
+                            let local_micros = micros + offset_secs * 1_000_000;

Review Comment:
   Sure, thanks @parthchandra for review. I’ll correct it, add the missing test, and update it in the next commit.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#issuecomment-4222632779

   Thanks to @parthchandra for the review and feedback. PR has been updated.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra merged PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3063429146


##########
spark/src/test/scala/org/apache/comet/CometTemporalExpressionSuite.scala:
##########
@@ -489,4 +489,58 @@ class CometTemporalExpressionSuite extends CometTestBase with AdaptiveSparkPlanH
         dummyDF.selectExpr("unix_date(cast(NULL as date))"))
     }
   }
+
+  /**
+   * Checks that the Comet-evaluated DataFrame produces the same results as the baseline DataFrame
+   * evaluated by native Spark JVM, and that Comet native operators are used. This is needed
+   * because Hours is a PartitionTransformExpression that extends Unevaluable.
+   */
+  private def checkHours(cometDF: DataFrame, baselineDF: DataFrame): Unit = {
+    // Ensure the expected answer is evaluated solely by native Spark JVM (Comet off)
+    var expected: Array[Row] = Array.empty
+    withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
+      expected = baselineDF.collect()
+    }
+    checkAnswer(cometDF, expected.toSeq)
+    checkCometOperators(stripAQEPlan(cometDF.queryExecution.executedPlan))
+  }
+
+  test("hours - timestamp input") {
+    import org.apache.spark.sql.catalyst.expressions.Hours
+    val r = new Random(42)
+    val tsSchema = StructType(Seq(StructField("ts", DataTypes.TimestampType, true)))
+    val tsDF = FuzzDataGenerator.generateDataFrame(r, spark, tsSchema, 1000, DataGenOptions())
+
+    for (timezone <- Seq("UTC", "America/Los_Angeles", "Asia/Tokyo")) {
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> timezone) {
+        checkHours(
+          tsDF.select(col("ts"), getColumnFromExpression(Hours(UnresolvedAttribute("ts")))),
+          tsDF.selectExpr("ts", "cast(floor(unix_micros(ts) / 3600000000D) as int)"))
+      }
+    }
+  }
+
+  test("hours - timestamp_ntz input") {
+    import org.apache.spark.sql.catalyst.expressions.Hours
+    val r = new Random(42)
+    val ntzSchema = StructType(Seq(StructField("ts", DataTypes.TimestampNTZType, true)))
+    val ntzDF = FuzzDataGenerator.generateDataFrame(r, spark, ntzSchema, 1000, DataGenOptions())
+
+    val _spark = spark
+    import _spark.implicits._
+    val expectedDF = ntzDF
+      .map { row =>
+        val ts = row.getAs[java.time.LocalDateTime]("ts")
+        val micros = if (ts != null) {
+          org.apache.spark.sql.catalyst.util.DateTimeUtils.localDateTimeToMicros(ts)
+        } else 0L // assuming safe non-null

Review Comment:
   Fixed. It now properly handles null values and returns null instead of 0.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#issuecomment-4240043785

   Merged. Thank you @0lai0 !


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#issuecomment-4228359140

   Thanks @parthchandra . Conflicts resolved and PR updated.


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3061432155


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,274 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! Both `TimestampType` and `TimestampNTZType` are computationally identical. They
+//! extract the absolute hours since the epoch by directly dividing the microsecond
+//! value by the number of microseconds in an hour, ignoring session timezone offsets.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+}
+
+impl SparkHoursTransform {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, _) => {
+                        arrow::compute::kernels::arity::unary(ts_array, |micros| {
+                            micros.div_euclid(MICROS_PER_HOUR) as i32

Review Comment:
   Why `div_euclid`? Elsewhere the code is generally using `div_floor`



##########
spark/src/main/scala/org/apache/comet/serde/datetime.scala:
##########
@@ -589,6 +589,36 @@ object CometDateFormat extends CometExpressionSerde[DateFormatClass] {
   }
 }
 
+/**
+ * Converts a timestamp to the number of hours since Unix epoch (1970-01-01 00:00:00 UTC). This is
+ * a V2 partition transform expression.
+ *
+ * Both TimestampType and TimestampNTZType use direct division of the raw microsecond value
+ * without applying any session timezone offset.
+ */
+object CometHours extends CometExpressionSerde[Hours] {
+  override def convert(
+      expr: Hours,
+      inputs: Seq[Attribute],
+      binding: Boolean): Option[ExprOuterClass.Expr] = {
+    val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+
+    if (childExpr.isDefined) {

Review Comment:
   It might be better to explicitly check the child expr datatype and only allow valid types, fall back otherwise.
   See `CometDays` below.  



##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,274 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! Both `TimestampType` and `TimestampNTZType` are computationally identical. They
+//! extract the absolute hours since the epoch by directly dividing the microsecond
+//! value by the number of microseconds in an hour, ignoring session timezone offsets.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+}
+
+impl SparkHoursTransform {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);

Review Comment:
   This should be after the `match` on `array.data_type`  in the `DataType::Timestamp(Microsecond, _)` arm. This would panic for other types.



##########
spark/src/test/scala/org/apache/comet/CometTemporalExpressionSuite.scala:
##########
@@ -489,4 +489,58 @@ class CometTemporalExpressionSuite extends CometTestBase with AdaptiveSparkPlanH
         dummyDF.selectExpr("unix_date(cast(NULL as date))"))
     }
   }
+
+  /**
+   * Checks that the Comet-evaluated DataFrame produces the same results as the baseline DataFrame
+   * evaluated by native Spark JVM, and that Comet native operators are used. This is needed
+   * because Hours is a PartitionTransformExpression that extends Unevaluable.
+   */
+  private def checkHours(cometDF: DataFrame, baselineDF: DataFrame): Unit = {
+    // Ensure the expected answer is evaluated solely by native Spark JVM (Comet off)
+    var expected: Array[Row] = Array.empty
+    withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
+      expected = baselineDF.collect()
+    }
+    checkAnswer(cometDF, expected.toSeq)
+    checkCometOperators(stripAQEPlan(cometDF.queryExecution.executedPlan))
+  }
+
+  test("hours - timestamp input") {
+    import org.apache.spark.sql.catalyst.expressions.Hours
+    val r = new Random(42)
+    val tsSchema = StructType(Seq(StructField("ts", DataTypes.TimestampType, true)))
+    val tsDF = FuzzDataGenerator.generateDataFrame(r, spark, tsSchema, 1000, DataGenOptions())
+
+    for (timezone <- Seq("UTC", "America/Los_Angeles", "Asia/Tokyo")) {
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> timezone) {
+        checkHours(
+          tsDF.select(col("ts"), getColumnFromExpression(Hours(UnresolvedAttribute("ts")))),
+          tsDF.selectExpr("ts", "cast(floor(unix_micros(ts) / 3600000000D) as int)"))
+      }
+    }
+  }
+
+  test("hours - timestamp_ntz input") {
+    import org.apache.spark.sql.catalyst.expressions.Hours
+    val r = new Random(42)
+    val ntzSchema = StructType(Seq(StructField("ts", DataTypes.TimestampNTZType, true)))
+    val ntzDF = FuzzDataGenerator.generateDataFrame(r, spark, ntzSchema, 1000, DataGenOptions())
+
+    val _spark = spark
+    import _spark.implicits._
+    val expectedDF = ntzDF
+      .map { row =>
+        val ts = row.getAs[java.time.LocalDateTime]("ts")
+        val micros = if (ts != null) {
+          org.apache.spark.sql.catalyst.util.DateTimeUtils.localDateTimeToMicros(ts)
+        } else 0L // assuming safe non-null

Review Comment:
   If the timestamp generated by the generator is `null`, then `hours` should return `null`. This will return `0`. 



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3063402086


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,274 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! Both `TimestampType` and `TimestampNTZType` are computationally identical. They
+//! extract the absolute hours since the epoch by directly dividing the microsecond
+//! value by the number of microseconds in an hour, ignoring session timezone offsets.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+}
+
+impl SparkHoursTransform {
+    pub fn new() -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, _) => {
+                        arrow::compute::kernels::arity::unary(ts_array, |micros| {
+                            micros.div_euclid(MICROS_PER_HOUR) as i32

Review Comment:
   Updated to use div_floor to match the rest of the codebase. Thanks for pointing this out!



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3063417397


##########
spark/src/main/scala/org/apache/comet/serde/datetime.scala:
##########
@@ -589,6 +589,36 @@ object CometDateFormat extends CometExpressionSerde[DateFormatClass] {
   }
 }
 
+/**
+ * Converts a timestamp to the number of hours since Unix epoch (1970-01-01 00:00:00 UTC). This is
+ * a V2 partition transform expression.
+ *
+ * Both TimestampType and TimestampNTZType use direct division of the raw microsecond value
+ * without applying any session timezone offset.
+ */
+object CometHours extends CometExpressionSerde[Hours] {
+  override def convert(
+      expr: Hours,
+      inputs: Seq[Attribute],
+      binding: Boolean): Option[ExprOuterClass.Expr] = {
+    val childExpr = exprToProtoInternal(expr.child, inputs, binding)
+
+    if (childExpr.isDefined) {

Review Comment:
   Fixed. Added explicit type checking to only allow TimestampType and TimestampNTZType, and it will now fall back for other types similarly to `CometDays`.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3047127823


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,299 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! - For `Timestamp(Microsecond, Some(tz))`: applies timezone offset before computing.
+//! - For `Timestamp(Microsecond, None)` (NTZ): uses raw microseconds directly.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use arrow::temporal_conversions::as_datetime;
+use chrono::{Offset, TimeZone};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+use crate::timezone::Tz;
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+    timezone: String,
+}
+
+impl SparkHoursTransform {
+    pub fn new(timezone: String) -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+            timezone,
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, Some(_)) => {
+                        let tz: Tz = self.timezone.parse().map_err(|e| {
+                            DataFusionError::Execution(format!(
+                                "Failed to parse timezone '{}': {}",
+                                self.timezone, e
+                            ))
+                        })?;
+                        arrow::compute::kernels::arity::try_unary(ts_array, |micros| {
+                            let dt = as_datetime::<TimestampMicrosecondType>(micros).ok_or_else(
+                                || {
+                                    DataFusionError::Execution(format!(
+                                        "Cannot convert {micros} to datetime"
+                                    ))
+                                },
+                            )?;
+                            let offset_secs =
+                                tz.offset_from_utc_datetime(&dt).fix().local_minus_utc() as i64;
+                            let local_micros = micros + offset_secs * 1_000_000;

Review Comment:
   Sure, thanks @parthchandra for review. I'll update in next commit.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] feat: Support Spark expression hours [datafusion-comet]

Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #3804:
URL: https://github.com/apache/datafusion-comet/pull/3804#discussion_r3042337792


##########
native/spark-expr/src/datetime_funcs/hours.rs:
##########
@@ -0,0 +1,299 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Spark-compatible `hours` V2 partition transform.
+//!
+//! Computes the number of hours since the Unix epoch (1970-01-01 00:00:00 UTC).
+//!
+//! - For `Timestamp(Microsecond, Some(tz))`: applies timezone offset before computing.
+//! - For `Timestamp(Microsecond, None)` (NTZ): uses raw microseconds directly.
+
+use arrow::array::cast::as_primitive_array;
+use arrow::array::types::TimestampMicrosecondType;
+use arrow::array::{Array, Int32Array};
+use arrow::datatypes::{DataType, TimeUnit::Microsecond};
+use arrow::temporal_conversions::as_datetime;
+use chrono::{Offset, TimeZone};
+use datafusion::common::{internal_datafusion_err, DataFusionError};
+use datafusion::logical_expr::{
+    ColumnarValue, ScalarFunctionArgs, ScalarUDFImpl, Signature, Volatility,
+};
+use std::{any::Any, fmt::Debug, sync::Arc};
+
+use crate::timezone::Tz;
+
+const MICROS_PER_HOUR: i64 = 3_600_000_000;
+
+#[derive(Debug, PartialEq, Eq, Hash)]
+pub struct SparkHoursTransform {
+    signature: Signature,
+    timezone: String,
+}
+
+impl SparkHoursTransform {
+    pub fn new(timezone: String) -> Self {
+        Self {
+            signature: Signature::user_defined(Volatility::Immutable),
+            timezone,
+        }
+    }
+}
+
+impl ScalarUDFImpl for SparkHoursTransform {
+    fn as_any(&self) -> &dyn Any {
+        self
+    }
+
+    fn name(&self) -> &str {
+        "hours_transform"
+    }
+
+    fn signature(&self) -> &Signature {
+        &self.signature
+    }
+
+    fn return_type(&self, _arg_types: &[DataType]) -> datafusion::common::Result<DataType> {
+        Ok(DataType::Int32)
+    }
+
+    fn invoke_with_args(
+        &self,
+        args: ScalarFunctionArgs,
+    ) -> datafusion::common::Result<ColumnarValue> {
+        let args: [ColumnarValue; 1] = args.args.try_into().map_err(|_| {
+            internal_datafusion_err!("hours_transform expects exactly one argument")
+        })?;
+
+        match args {
+            [ColumnarValue::Array(array)] => {
+                let ts_array = as_primitive_array::<TimestampMicrosecondType>(&array);
+                let result: Int32Array = match array.data_type() {
+                    DataType::Timestamp(Microsecond, Some(_)) => {
+                        let tz: Tz = self.timezone.parse().map_err(|e| {
+                            DataFusionError::Execution(format!(
+                                "Failed to parse timezone '{}': {}",
+                                self.timezone, e
+                            ))
+                        })?;
+                        arrow::compute::kernels::arity::try_unary(ts_array, |micros| {
+                            let dt = as_datetime::<TimestampMicrosecondType>(micros).ok_or_else(
+                                || {
+                                    DataFusionError::Execution(format!(
+                                        "Cannot convert {micros} to datetime"
+                                    ))
+                                },
+                            )?;
+                            let offset_secs =
+                                tz.offset_from_utc_datetime(&dt).fix().local_minus_utc() as i64;
+                            let local_micros = micros + offset_secs * 1_000_000;

Review Comment:
   In Spark's corresponding implementation in [InMemoryBaseTable ](https://github.com/apache/spark/blob/af9c8b346673c0ffa79ce3b0a76e53e9df51fe76/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/InMemoryBaseTable.scala#L232) it looks like the session timezone is not being applied. 
   Can you add a unit test that reads from InMemoryBaseTable and compares with the results produced by Spark ?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org