sunchao commented on code in PR #6938:
URL: https://github.com/apache/datafusion-comet/pull/6938#discussion_r4446971058


##########
spark/src/test/resources/sql-tests/join/cartesian_product.sql:
##########
@@ -0,0 +1,86 @@
+-- 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.
+
+-- Tests for CartesianProductExec, which Spark plans for a cross join with no 
equi key when
+-- nothing is broadcast. Comet runs it natively only without a condition and 
when each input
+-- reports exactly one partition. A non-bucketed Parquet scan reports 
UnknownPartitioning(0), so
+-- each side is coalesced to one partition. Partition coalescing is off so AQE 
cannot merge the
+-- REPARTITION(2) case, and the tiny advisory size makes AQE try to split the 
REBALANCE(1) case.
+
+-- Config: spark.comet.exec.cartesianProduct.enabled=true
+-- Config: spark.sql.autoBroadcastJoinThreshold=-1
+-- Config: spark.sql.adaptive.autoBroadcastJoinThreshold=-1
+-- Config: spark.sql.adaptive.coalescePartitions.enabled=false
+-- Config: spark.sql.adaptive.advisoryPartitionSizeInBytes=1k
+-- ConfigMatrix: spark.sql.adaptive.enabled=true,false
+
+statement
+CREATE TABLE cp_left(k int, v int) USING parquet
+
+statement
+INSERT INTO cp_left VALUES (0, 10), (NULL, 11), (2, NULL), (NULL, NULL)
+
+statement
+CREATE TABLE cp_right(k int, v int) USING parquet
+
+statement
+INSERT INTO cp_right VALUES (0, 100), (NULL, NULL)
+
+statement
+CREATE TABLE cp_empty(k int, v int) USING parquet
+
+statement
+CREATE TABLE cp_large(k int, v int) USING parquet
+
+-- More rows than the default batch size of 8192.
+statement
+INSERT INTO cp_large SELECT id, id FROM range(10000)
+
+-- Native, with NULLs on both sides
+query
+SELECT * FROM (SELECT /*+ COALESCE(1) */ * FROM cp_left) l
+CROSS JOIN (SELECT /*+ COALESCE(1) */ * FROM cp_right) r
+
+-- Native, empty left side (the side CrossJoinExec buffers)
+query
+SELECT * FROM (SELECT /*+ COALESCE(1) */ * FROM cp_empty) l
+CROSS JOIN (SELECT /*+ COALESCE(1) */ * FROM cp_right) r
+
+-- Native, empty right side
+query
+SELECT * FROM (SELECT /*+ COALESCE(1) */ * FROM cp_left) l
+CROSS JOIN (SELECT /*+ COALESCE(1) */ * FROM cp_empty) r
+
+-- Native, right side spanning several batches
+query
+SELECT * FROM (SELECT /*+ COALESCE(1) */ * FROM cp_left) l
+CROSS JOIN (SELECT /*+ COALESCE(1) */ * FROM cp_large) r
+
+-- Native, AQE must not split the REBALANCE(1) input into several partitions
+query
+SELECT * FROM (SELECT /*+ REBALANCE(1) */ * FROM cp_large) l

Review Comment:
   Could this REBALANCE case run only with AQE enabled? The fixture's 
`ConfigMatrix` also runs it with `spark.sql.adaptive.enabled=false`, where 
Spark ignores `REBALANCE(1)`. The plain Parquet left input then reports 
`UnknownPartitioning(0)`, so the single-partition guard correctly falls back, 
but `query` requires a fully native plan. I reproduced the hint/partitioning 
behavior on Spark 4.1.3, and the exact-head fork [expressions 
job](https://github.com/coderfender/datafusion-comet/actions/runs/41332421694/job/125143465129)
 passes the AQE=true fixture and fails AQE=false at this query. Keeping the 
other cases in both configurations and moving this one to an AQE-only fixture 
would retain the intended coverage.



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