Copilot commented on code in PR #12967:
URL: https://github.com/apache/gluten/pull/12967#discussion_r3937268049


##########
cpp/velox/substrait/VeloxSubstraitSignature.cc:
##########
@@ -155,6 +158,10 @@ TypePtr 
VeloxSubstraitSignature::fromSubstraitSignature(const std::string& signa
     return TIMESTAMP();
   }
 
+  if (signature == "tsntz") {

Review Comment:
   The signature token for TIMESTAMP_NTZ has changed (previously `ts_ntz`, now 
`tsntz`). If any previously serialized Substrait plans/signatures still use 
`ts_ntz`, `fromSubstraitSignature` will fail to interpret them. Consider 
accepting both `tsntz` and the legacy `ts_ntz` token during parsing (while 
continuing to emit only `tsntz`) to preserve backward compatibility.



##########
gluten-ut/spark41/src/test/scala/org/apache/spark/sql/GlutenTimestampNtzAggregateSuite.scala:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+package org.apache.spark.sql
+
+import org.apache.gluten.config.GlutenConfig
+import org.apache.gluten.execution.{HashAggregateExecBaseTransformer, 
ProjectExecTransformer}
+
+import org.apache.spark.sql.functions.{max, min}
+import org.apache.spark.sql.internal.SQLConf
+
+import java.time.LocalDateTime
+
+class GlutenTimestampNtzAggregateSuite extends GlutenSQLTestsTrait {
+
+  import testImplicits._
+
+  testGluten("min and max") {
+    withSQLConf(
+      SQLConf.ANSI_ENABLED.key -> "false",
+      GlutenConfig.GLUTEN_ANSI_FALLBACK_ENABLED.key -> "false") {
+      withTempPath {
+        path =>
+          Seq(
+            "1969-12-31 23:59:59.999999",
+            "2024-01-01 00:00:00.123456"
+          ).toDF("input")
+            .selectExpr("cast(input as timestamp_ntz) as ts")
+            .write
+            .parquet(path.getCanonicalPath)
+
+          val result = 
spark.read.parquet(path.getCanonicalPath).agg(min($"ts"), max($"ts"))
+          checkAnswer(
+            result,
+            Row(
+              LocalDateTime.parse("1969-12-31T23:59:59.999999"),
+              LocalDateTime.parse("2024-01-01T00:00:00.123456")))
+          assert(
+            
getExecutedPlan(result).exists(_.isInstanceOf[HashAggregateExecBaseTransformer]),
+            result.queryExecution.executedPlan.treeString)
+      }
+    }
+  }
+
+  testGluten("unsupported project falls back") {
+    withSQLConf(
+      SQLConf.ANSI_ENABLED.key -> "false",
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles",
+      GlutenConfig.GLUTEN_ANSI_FALLBACK_ENABLED.key -> "false") {
+      withTempPath {
+        path =>
+          Seq("2024-01-01 00:00:00.123456")
+            .toDF("input")
+            .selectExpr("cast(input as timestamp_ntz) as ts")
+            .write
+            .parquet(path.getCanonicalPath)
+
+          val result = spark.read
+            .parquet(path.getCanonicalPath)
+            .selectExpr("to_json(named_struct('ts', ts))")
+          checkAnswer(result, Row("""{"ts":"2024-01-01T00:00:00.123"}"""))
+          assert(
+            
!getExecutedPlan(result).exists(_.isInstanceOf[ProjectExecTransformer]),
+            result.queryExecution.executedPlan.treeString)

Review Comment:
   This assertion is brittle because it fails if *any* `ProjectExecTransformer` 
appears anywhere in the executed plan (even if unrelated to the 
`to_json(named_struct(...))` projection being tested). To make the test more 
stable, assert fallback more locally—e.g., identify the specific `ProjectExec` 
corresponding to the `to_json` expression and verify that node is not 
transformed (or verify that the plan contains a non-transformer `ProjectExec` 
for that projection).



-- 
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