Skip to content

Conversation

@mihailotim-db
Copy link
Contributor

What changes were proposed in this pull request?

Fix issue when laterally referencing a Generator.

Why are the changes needed?

Fix the following query pattern:

WITH cte AS (SELECT EXPLODE(ARRAY(1, 2, 3)) AS c1, c1) SELECT * FROM cte

Does this PR introduce any user-facing change?

No

How was this patch tested?

Added a test case to LateralColumnAliasSuite

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

No

@github-actions github-actions bot added the SQL label Mar 18, 2025
@mihailotim-db mihailotim-db force-pushed the mihailotim-db/generator_lca branch 4 times, most recently from bc0c013 to 70c6828 Compare March 19, 2025 09:00
@mihailotim-db mihailotim-db force-pushed the mihailotim-db/generator_lca branch from 70c6828 to 5ab688f Compare March 19, 2025 11:42
sql("select 1 as a, a").queryExecution.assertAnalyzed()
}

test("SPARK-49349: Improve error message for LCA with Generate") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test now passes so refactoring it a bit

@cloud-fan
Copy link
Contributor

This is a partial revert of #45350 . I don't quite like this fix, but seems this is the only way to fix the conflicts between two rules.

  1. ExtractGenerator needs to wait for the projectList to be resolved (except for the generator itself) before pulling generator out into a Generate node.
  2. Column resolution rule needs to wait for the generator to be resolved before marking its corresponding LateralColumnAliasReference as resolved.

Now we relax the trigger condition of rule ExtractGeneraton to fix the conflicts.

@cloud-fan
Copy link
Contributor

thanks, merging to master/4.0/3.5!

@cloud-fan cloud-fan closed this in 62c0669 Mar 20, 2025
cloud-fan pushed a commit that referenced this pull request Mar 20, 2025
…Generator`

### What changes were proposed in this pull request?
Fix issue when laterally referencing a `Generator`.

### Why are the changes needed?
Fix the following query pattern:
```
WITH cte AS (SELECT EXPLODE(ARRAY(1, 2, 3)) AS c1, c1) SELECT * FROM cte
```

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Added a test case to `LateralColumnAliasSuite`

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

Closes #50310 from mihailotim-db/mihailotim-db/generator_lca.

Authored-by: Mihailo Timotic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 62c0669)
Signed-off-by: Wenchen Fan <[email protected]>
cloud-fan pushed a commit that referenced this pull request Mar 20, 2025
…Generator`

Fix issue when laterally referencing a `Generator`.

Fix the following query pattern:
```
WITH cte AS (SELECT EXPLODE(ARRAY(1, 2, 3)) AS c1, c1) SELECT * FROM cte
```

No

Added a test case to `LateralColumnAliasSuite`

No

Closes #50310 from mihailotim-db/mihailotim-db/generator_lca.

Authored-by: Mihailo Timotic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 62c0669)
Signed-off-by: Wenchen Fan <[email protected]>
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 14, 2025
…Generator`

### What changes were proposed in this pull request?
Fix issue when laterally referencing a `Generator`.

### Why are the changes needed?
Fix the following query pattern:
```
WITH cte AS (SELECT EXPLODE(ARRAY(1, 2, 3)) AS c1, c1) SELECT * FROM cte
```

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Added a test case to `LateralColumnAliasSuite`

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

Closes apache#50310 from mihailotim-db/mihailotim-db/generator_lca.

Authored-by: Mihailo Timotic <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 3fb6549)
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants