Skip to content

[SPARK-56814][SQL][TESTS] Add lateral join tests for outer attribute visibility after NATURAL/USING JOIN#55794

Closed
mihailotim-db wants to merge 1 commit into
apache:masterfrom
mihailotim-db:mihailo-timotic_data/lateral-join-outer-attr-visibility
Closed

[SPARK-56814][SQL][TESTS] Add lateral join tests for outer attribute visibility after NATURAL/USING JOIN#55794
mihailotim-db wants to merge 1 commit into
apache:masterfrom
mihailotim-db:mihailo-timotic_data/lateral-join-outer-attr-visibility

Conversation

@mihailotim-db
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add SQL query test cases to join-lateral.sql covering lateral join outer attribute visibility after NATURAL JOIN and USING JOIN. Specifically:

  1. Lateral after NATURAL JOIN -- unqualified key: verifies the merged join key resolves correctly in the lateral subquery.
  2. Lateral after NATURAL JOIN -- qualified keys: verifies t1.k and t2.k resolve to the original pre-merge columns.
  3. Lateral after USING JOIN -- qualified keys: same as above but with explicit USING (k) syntax.
  4. Lateral cannot see column hidden by subquery alias: verifies that a column not in the subquery's output (v1 behind SELECT k FROM ... ORDER BY v1)
    is not visible to the lateral subquery.
  5. Lateral cannot see column not in GROUP BY output: verifies that a column dropped by GROUP BY projection (v1 in SELECT k FROM ... GROUP BY k) is not
    visible to the lateral subquery.

Why are the changes needed?

The existing join-lateral.sql tests cover NATURAL JOIN and USING JOIN with the lateral subquery itself (lines 28-29), but do not test lateral joins chained after a NATURAL/USING JOIN -- i.e., whether the merged/qualified/hidden columns from the left side are correctly visible or hidden across the lateral boundary. These tests close that gap.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added test cases

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

Generated-by: Claude Code (claude-opus-4-6)

…ter NATURAL/USING JOIN

Co-authored-by: Isaac
Copy link
Copy Markdown
Contributor

@vladimirg-db vladimirg-db left a comment

Choose a reason for hiding this comment

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

Thanks!

@cloud-fan
Copy link
Copy Markdown
Contributor

thanks, merging to master/4.x/4.2!

@cloud-fan cloud-fan closed this in 52daa61 May 11, 2026
cloud-fan pushed a commit that referenced this pull request May 11, 2026
…visibility after NATURAL/USING JOIN

## What changes were proposed in this pull request?

Add SQL query test cases to join-lateral.sql covering lateral join outer attribute visibility after NATURAL JOIN and USING JOIN. Specifically:

  1. Lateral after NATURAL JOIN -- unqualified key: verifies the merged join key resolves correctly in the lateral subquery.
  2. Lateral after NATURAL JOIN -- qualified keys: verifies t1.k and t2.k resolve to the original pre-merge columns.
  3. Lateral after USING JOIN -- qualified keys: same as above but with explicit USING (k) syntax.
  4. Lateral cannot see column hidden by subquery alias: verifies that a column not in the subquery's output (v1 behind SELECT k FROM ... ORDER BY v1)
  is not visible to the lateral subquery.
  5. Lateral cannot see column not in GROUP BY output: verifies that a column dropped by GROUP BY projection (v1 in SELECT k FROM ... GROUP BY k) is not
   visible to the lateral subquery.

##  Why are the changes needed?

The existing join-lateral.sql tests cover NATURAL JOIN and USING JOIN with the lateral subquery itself (lines 28-29), but do not test lateral joins chained after a NATURAL/USING JOIN -- i.e., whether the merged/qualified/hidden columns from the left side are correctly visible or hidden across the lateral boundary. These tests close that gap.

## Does this PR introduce any user-facing change?

No.

## How was this patch tested?

 Added test cases

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

Generated-by: Claude Code (claude-opus-4-6)

Closes #55794 from mihailotim-db/mihailo-timotic_data/lateral-join-outer-attr-visibility.

Authored-by: Mihailo Timotic <mihailo.timotic@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 52daa61)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan pushed a commit that referenced this pull request May 11, 2026
…visibility after NATURAL/USING JOIN

## What changes were proposed in this pull request?

Add SQL query test cases to join-lateral.sql covering lateral join outer attribute visibility after NATURAL JOIN and USING JOIN. Specifically:

  1. Lateral after NATURAL JOIN -- unqualified key: verifies the merged join key resolves correctly in the lateral subquery.
  2. Lateral after NATURAL JOIN -- qualified keys: verifies t1.k and t2.k resolve to the original pre-merge columns.
  3. Lateral after USING JOIN -- qualified keys: same as above but with explicit USING (k) syntax.
  4. Lateral cannot see column hidden by subquery alias: verifies that a column not in the subquery's output (v1 behind SELECT k FROM ... ORDER BY v1)
  is not visible to the lateral subquery.
  5. Lateral cannot see column not in GROUP BY output: verifies that a column dropped by GROUP BY projection (v1 in SELECT k FROM ... GROUP BY k) is not
   visible to the lateral subquery.

##  Why are the changes needed?

The existing join-lateral.sql tests cover NATURAL JOIN and USING JOIN with the lateral subquery itself (lines 28-29), but do not test lateral joins chained after a NATURAL/USING JOIN -- i.e., whether the merged/qualified/hidden columns from the left side are correctly visible or hidden across the lateral boundary. These tests close that gap.

## Does this PR introduce any user-facing change?

No.

## How was this patch tested?

 Added test cases

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

Generated-by: Claude Code (claude-opus-4-6)

Closes #55794 from mihailotim-db/mihailo-timotic_data/lateral-join-outer-attr-visibility.

Authored-by: Mihailo Timotic <mihailo.timotic@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 52daa61)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
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.

3 participants