zhengruifeng commented on code in PR #38778:
URL: https://github.com/apache/spark/pull/38778#discussion_r1035853820
##########
python/pyspark/sql/tests/connect/test_connect_basic.py:
##########
@@ -722,6 +722,19 @@ def test_write_operations(self):
ndf = self.connect.read.table("parquet_test")
self.assertEqual(set(df.collect()), set(ndf.collect()))
+ def test_crossjoin(self):
+ # SPARK-41227: Test CrossJoin
+ connect_df = self.connect.read.table(self.tbl_name)
+ spark_df = self.spark.read.table(self.tbl_name)
+ self.assertEqual(
+ connect_df.join(other=connect_df, how="cross").toPandas(),
+ spark_df.join(other=spark_df, how="cross").toPandas(),
+ )
+ self.assertEqual(
Review Comment:
ahhh, the columns are duplicated:
```
In [1]: df = spark.createDataFrame([(10, 80, "Alice"), (5, None, "Bob"),
(None, 10, "Tom"), (None, None, None)], schema=["age", "height",
...: "name"])
In [2]: df.crossJoin(df).show()
+----+------+-----+----+------+-----+
| age|height| name| age|height| name|
+----+------+-----+----+------+-----+
| 10| 80|Alice| 10| 80|Alice|
| 10| 80|Alice| 5| null| Bob|
| 10| 80|Alice|null| 10| Tom|
```
I think you can use test it like this:
```
self.assertEqual(
set(connect_df.select("id").join(other=connect_df.select("name"),
how="cross").toPandas()),
set(spark_df.select("id").join(other=spark_df.select("name"),
how="cross").toPandas()),
)
```
--
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]