Skip to content

[MINOR][PYTHON][DOCS] Add example to Column.outer docstring#57199

Open
CynicDog wants to merge 2 commits into
apache:masterfrom
CynicDog:column-outer-doc-examples
Open

[MINOR][PYTHON][DOCS] Add example to Column.outer docstring#57199
CynicDog wants to merge 2 commits into
apache:masterfrom
CynicDog:column-outer-doc-examples

Conversation

@CynicDog

@CynicDog CynicDog commented Jul 11, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Adds an Examples section to Column.outer()'s docstring in python/pyspark/sql/column.py. Every other Column method in this file has a worked example; outer() was the one exception.

The example builds a small employees DataFrame and uses .outer() inside a correlated scalar subquery to filter employees earning above their department's average salary.

Why are the changes needed?

outer() is easy to misunderstand from the description alone, since its effect (marking a column so it resolves against an outer query) only makes sense in the context of a correlated subquery. A concrete example makes that immediately clear, consistent with the rest of the file.

Does this PR introduce any user-facing change?

No. Documentation-only change (a docstring example).

How was this patch tested?

Built Spark locally (build/sbt -Phive package) and ran the Column.outer doctest directly against the built jars to confirm the example's output matches exactly.

Was this patch authored or co-authored using generative AI tooling?

Yes, co-authored. The code example and documentation text were authored by me, but I used Claude as a peer-review to validate the clarity of the example and check for edge cases before submission.

CynicDog added 2 commits July 11, 2026 20:58
Column.outer had no worked example showing how it's used to build a
correlated subquery, unlike the other Column methods in this file.
|name|salary|department_id|
+----+------+-------------+
| Bob| 6000| 101|
+----+------+-------------+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left just one comment, otherwise LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants