zhengruifeng commented on code in PR #45846:
URL: https://github.com/apache/spark/pull/45846#discussion_r1550693431


##########
python/pyspark/sql/tests/connect/test_connect_basic.py:
##########
@@ -1155,6 +1155,15 @@ def test_crossjoin(self):
             
set(spark_df.select("id").crossJoin(other=spark_df.select("name")).toPandas()),
         )
 
+    def test_self_join(self):
+        # SPARK-47713: this query fails in classic spark
+        df1 = self.connect.createDataFrame([(1, "a")], schema=["i", "j"])
+        df1_filter = df1.filter(df1.i > 0)
+        df2 = df1.join(df1_filter, df1.i == 1)
+        self.assertEqual(df2.count(), 1)
+        self.assertEqual(df2.columns, ["i", "j", "i", "j"])
+        self.assertEqual(list(df2.first()), [1, "a", 1, "a"])

Review Comment:
   `Row` constructor doesn't accept duplicated names, so test in this way
   
   <img width="271" alt="image" 
src="https://github.com/apache/spark/assets/7322292/80528560-dd47-4413-b80a-17a83b310b53";>
   



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