@@ -242,11 +242,10 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
242242 }
243243 }
244244
245- // Floats nested in array and struct sort keys are normalized natively as well, but strict mode
246- // declines a key whose type can hold a null element or field: Spark orders that null below
247- // every value whatever the key's null order, and the native sort places it by the null order
248- // (#6476). Every field the generator makes is nullable, so these sorts fall back. A unique `id`
249- // sorted last makes the ordering total, as above.
245+ // Floats nested in array and struct sort keys are normalized natively, in strict mode too. A key
246+ // whose type can hold a null element or field sorts natively under the default null order, which
247+ // agrees with Spark's. Every field the generator makes is nullable. A unique `id` sorted last
248+ // makes the ordering total, as above.
250249 private def checkStrictNestedFloatingPointSort (schema : StructType ): Unit = {
251250 val df = FuzzDataGenerator .generateDataFrame(
252251 new Random (42 ),
@@ -260,21 +259,15 @@ class CometExpressionSuite extends CometTestBase with AdaptiveSparkPlanHelper {
260259 df.withColumn(" id" , monotonically_increasing_id()).write.parquet(path)
261260 spark.read.parquet(path).createOrReplaceTempView(" tbl" )
262261
263- withSQLConf(
264- CometConf .getExprAllowIncompatConfigKey(" SortOrder" ) -> " false" ,
265- CometConf .COMET_EXEC_STRICT_FLOATING_POINT .key -> " true" ) {
266- checkSparkAnswerAndFallbackReason(
267- sql(" select * from tbl order by 1, 2, 3" ),
268- " can hold a null element or field" )
269- }
270-
271- // The default null order agrees with Spark's, so opting in keeps the sort native and right.
272- withSQLConf(
273- CometConf .getExprAllowIncompatConfigKey(" SortOrder" ) -> " true" ,
274- CometConf .COMET_EXEC_STRICT_FLOATING_POINT .key -> " true" ) {
275- checkSparkAnswerAndOperator(
276- sql(" select * from tbl order by 1, 2, 3" ),
277- Seq (classOf [CometSortExec ]))
262+ // The sort stays native whether or not incompatible expressions are allowed.
263+ Seq (" false" , " true" ).foreach { allowIncompat =>
264+ withSQLConf(
265+ CometConf .getExprAllowIncompatConfigKey(" SortOrder" ) -> allowIncompat,
266+ CometConf .COMET_EXEC_STRICT_FLOATING_POINT .key -> " true" ) {
267+ checkSparkAnswerAndOperator(
268+ sql(" select * from tbl order by 1, 2, 3" ),
269+ Seq (classOf [CometSortExec ]))
270+ }
278271 }
279272 }
280273 }
0 commit comments