uros-b commented on code in PR #57199:
URL: https://github.com/apache/spark/pull/57199#discussion_r3583221227


##########
python/pyspark/sql/column.py:
##########
@@ -1578,6 +1578,24 @@ def outer(self) -> "Column":
         --------
         pyspark.sql.dataframe.DataFrame.scalar
         pyspark.sql.dataframe.DataFrame.exists
+
+        Examples
+        --------
+        >>> from pyspark.sql import functions as sf
+        >>> employees = spark.createDataFrame(
+        ...     [(1, "Alice", 5000, 101), (2, "Bob", 6000, 101), (3, 
"Charlie", 4500, 102)],
+        ...     ["id", "name", "salary", "department_id"],
+        ... )
+        >>> employees.alias("e1").where(
+        ...     sf.col("salary") > employees.alias("e2").where(
+        ...         sf.col("e2.department_id") == 
sf.col("e1.department_id").outer()
+        ...     ).select(sf.avg("salary")).scalar()
+        ... ).select("name", "salary", "department_id").orderBy("name").show()
+        +----+------+-------------+
+        |name|salary|department_id|
+        +----+------+-------------+
+        | Bob|  6000|          101|
+        +----+------+-------------+

Review Comment:
   Nit: the 3-row dataset puts a single employee (Charlie, 4500) in dept 102, 
so avg == 4500 and Charlie fails the strict > filter, leaving dept 102 with no 
qualifying row. The shown output is a single row (Bob), which a reader may find 
slightly opaque (why are two of three names absent?). Consider mirroring 
DataFrame.scalar() Example 2's richer dataset so both departments yield at 
least one qualifying row. The math is correct, this is just a readability 
suggestion.



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