andygrove commented on code in PR #5889:
URL: https://github.com/apache/datafusion-comet/pull/5889#discussion_r4222470898
##########
spark/src/main/scala/org/apache/spark/sql/comet/execution/arrow/CometArrowConverters.scala:
##########
@@ -46,6 +54,53 @@ import org.apache.comet.vector.NativeUtil
*/
object CometArrowConverters extends Logging {
+ /**
+ * Serialize a scalar subquery result as one struct column containing one
row. Keeping the
+ * struct as a column preserves the distinction between a null struct and a
struct whose fields
+ * are all null. Native execution expects TimestampType fields to carry the
UTC zone.
+ */
+ def serializeScalarSubquery(row: InternalRow, dataType: StructType):
Array[Byte] = {
+ val schema = StructType(Seq(StructField("value", dataType, nullable =
true)))
+ val output = new ByteArrayOutputStream()
+ Using.resource(
+ VectorSchemaRoot.create(Utils.toArrowSchema(schema, "UTC"),
CometArrowAllocator)) { root =>
Review Comment:
Could this use `CometArrowStream.NATIVE_TIMEZONE` rather than the literal
`"UTC"`? `timezones.md` says every JVM producer uses that constant.
##########
spark/src/test/resources/sql-tests/expressions/misc/scalar_subquery_struct.sql:
##########
@@ -0,0 +1,143 @@
+-- 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.
+
+-- Config: spark.sql.session.timeZone=UTC
Review Comment:
Since timestamps in these structs now cross into native code, could this run
under `-- ConfigMatrix: spark.sql.session.timeZone=UTC,America/Los_Angeles`,
with a query that casts or compares `s.instant` rather than only projecting it?
Both pass with the current code when I try them.
--
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]