sunchao commented on code in PR #6428: URL: https://github.com/apache/datafusion-comet/pull/6428#discussion_r4178688662
########## spark/src/test/resources/sql-tests/expressions/struct/create_named_struct_nullability.sql: ########## @@ -0,0 +1,61 @@ +-- 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.comet.sparkToColumnar.enabled=true +-- Config: spark.comet.sparkToColumnar.supportedOperatorList=Range +-- Config: spark.sql.caseSensitive=false + +-- Catalyst proves BIGINT -> DOUBLE nonnullable; native cast inference is conservative. +-- The computed struct must have the same field flags as the typed NULL array element. +query +SELECT array(named_struct('score', CAST(id AS DOUBLE), + 'amount', CAST(id AS DECIMAL(18,2))), NULL) +FROM range(8) + +-- The field contract must also survive a nested constructor with an actually nullable child. +query +SELECT array(named_struct('nested', named_struct('score', CAST(id AS DOUBLE), + 'optional', CASE WHEN id % 2 = 0 THEN id END)), NULL) +FROM range(8) + +-- CASE unions nullability by ordinal, even when case-insensitive names swap places. +query +SELECT CASE WHEN id % 2 = 0 + THEN named_struct('x', CAST(id AS DOUBLE), 'X', CAST(NULL AS DOUBLE)) + ELSE named_struct('X', CAST(NULL AS DOUBLE), 'x', CAST(id AS DOUBLE)) +END FROM range(8) + +-- An untyped NULL branch must not restore name-based struct coercion. +query +SELECT CASE WHEN id % 3 = 0 + THEN named_struct('x', CAST(id AS DOUBLE), 'X', CAST(NULL AS DOUBLE)) + WHEN id % 3 = 1 THEN NULL + ELSE named_struct('X', CAST(NULL AS DOUBLE), 'x', CAST(id AS DOUBLE)) +END FROM range(8) + +-- Spark compares struct fields by position, irrespective of field names. +query +SELECT named_struct('x', CAST(id AS DOUBLE), 'y', CAST(NULL AS DOUBLE)) = Review Comment: Fixed in `8580cb0040`: the different-name comparison now has a separate fixture gated with `MinSparkVersion: 4.0`; the other five queries remain available on Spark 3.x. Both fixture files pass locally on Spark 4.1.3. The conflict rebase retains main’s current IF/CASE factories, and the native nested-IF regression plus native/JVM builds pass. Other profiles are requested in CI. -- 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]
