Skip to content

Conversation

@cloud-fan
Copy link
Contributor

What changes were proposed in this pull request?

This is a followup of #38862 . #38862 only handles plan alias, but expression alias is missed. This PR fixes it.

Why are the changes needed?

fix a regression

Does this PR introduce any user-facing change?

Yes, certain querys that failed with UNRESOLVED_COLUMN before this PR can work now.

How was this patch tested?

new tests

@cloud-fan cloud-fan marked this pull request as ready for review December 15, 2022 14:00
@github-actions github-actions bot added the SQL label Dec 15, 2022
@cloud-fan
Copy link
Contributor Author

cc @viirya @MaxGekk

@MaxGekk
Copy link
Member

MaxGekk commented Dec 15, 2022

+1, LGTM. Merging to 3.3/master.
Thank you, @cloud-fan and @viirya for review.

@MaxGekk MaxGekk closed this in cd117fb Dec 15, 2022
@MaxGekk
Copy link
Member

MaxGekk commented Dec 15, 2022

@cloud-fan This causes conflicts in branch-3.3. Please, open a separate PR if it is needed.

cloud-fan added a commit to cloud-fan/spark that referenced this pull request Dec 19, 2022
…columns after alias

This is a followup of apache#38862 . apache#38862 only handles plan alias, but expression alias is missed. This PR fixes it.

fix a regression

Yes, certain querys that failed with `UNRESOLVED_COLUMN` before this PR can work now.

new tests

Closes apache#39077 from cloud-fan/bug.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
@cloud-fan
Copy link
Contributor Author

3.3 PR created #39121

cloud-fan added a commit that referenced this pull request Dec 22, 2022
…dden columns after alias

backport #39077 to 3.3

Closes #39121 from cloud-fan/backport.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
cloud-fan added a commit that referenced this pull request Jan 18, 2023
### What changes were proposed in this pull request?

This is a better fix than #39077 and #38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

### Why are the changes needed?

To make the join hidden column feature more robust

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

No

### How was this patch tested?

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
cloud-fan added a commit that referenced this pull request Jan 18, 2023
This is a better fix than #39077 and #38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

To make the join hidden column feature more robust

No

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
a0x8o added a commit to a0x8o/spark that referenced this pull request Jan 18, 2023
### What changes were proposed in this pull request?

This is a better fix than apache/spark#39077 and apache/spark#38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

### Why are the changes needed?

To make the join hidden column feature more robust

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

No

### How was this patch tested?

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
a0x8o added a commit to a0x8o/spark that referenced this pull request Jan 18, 2023
### What changes were proposed in this pull request?

This is a better fix than apache/spark#39077 and apache/spark#38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

### Why are the changes needed?

To make the join hidden column feature more robust

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

No

### How was this patch tested?

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
a0x8o added a commit to a0x8o/spark that referenced this pull request Jan 18, 2023
### What changes were proposed in this pull request?

This is a better fix than apache/spark#39077 and apache/spark#38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

### Why are the changes needed?

To make the join hidden column feature more robust

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

No

### How was this patch tested?

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
a0x8o added a commit to a0x8o/spark that referenced this pull request Jul 29, 2024
### What changes were proposed in this pull request?

This is a better fix than apache/spark#39077 and apache/spark#38862

The special attribute metadata `__qualified_access_only` is very risky, as it breaks normal column resolution. The aforementioned 2 PRs remove the restriction in `SubqueryAlias` and `Alias`, but it's not good enough as we may forget to do the same thing for new logical plans/expressions in the future. It's also problematic if advanced users manipulate logical plans and expressions directly, when there is no `SubqueryAlias` and `Alias` to remove the restriction.

To be safe, we should only apply this restriction when resolving join hidden columns, which means the plan node right above `Project(Join(using or natural join))`. This PR simply removes the restriction when a column is resolved from a sequence of `Attributes`, or from star expansion, and also when adding the `Project` hidden columns to its output. This makes sure that the qualified-access-only restriction will not be leaked to normal column resolution, but only metadata column resolution.

### Why are the changes needed?

To make the join hidden column feature more robust

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

No

### How was this patch tested?

existing tests

Closes #39596 from cloud-fan/join.

Authored-by: Wenchen Fan <[email protected]>
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.

3 participants