Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-51589][SQL] Fix small bug failing to check for aggregate functions in |> SELECT #50352

Closed
wants to merge 1 commit into from

Conversation

dtenedor
Copy link
Contributor

@dtenedor dtenedor commented Mar 22, 2025

What changes were proposed in this pull request?

This PR fixes a small bug with |> SELECT with aggregate functions without aliases. In such cases, we should be returning an error instructing the user to use |> AGGREGATE instead, but we do not.

This bug only happens when the aggregate function does not have any alias.

For example:

VALUES (0), (1) tab(col)
|> SELECT SUM(col)

Before this PR, the above query returned a result of 1. After this PR, the above query instead returns an error instructing the user to switch to |> AGGREGATE to perform the sum operation instead.

Why are the changes needed?

The documented behavior of |> SELECT is that the expression list must not contain any aggregate functions, and the user receives an error otherwise.

Does this PR introduce any user-facing change?

Yes, see above.

How was this patch tested?

This PR adds golden file based test coverage.

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

No.

@github-actions github-actions bot added the SQL label Mar 22, 2025
@dtenedor
Copy link
Contributor Author

👋 Here is a small bug fix, cc @dongjoon-hyun @cloud-fan @gengliangwang

@cloud-fan
Copy link
Contributor

thanks, merging to master/4.0!

@cloud-fan cloud-fan closed this in 1ede242 Mar 24, 2025
cloud-fan pushed a commit that referenced this pull request Mar 24, 2025
…ions in |> SELECT

### What changes were proposed in this pull request?

This PR fixes a small bug with `|> SELECT` with aggregate functions without aliases. In such cases, we should be returning an error instructing the user to use `|> AGGREGATE` instead, but we do not.

This bug only happens when the aggregate function does not have any alias.

For example:

```
VALUES (0), (1) tab(col)
|> SELECT SUM(col)
```

Before this PR, the above query returned a result of 1. After this PR, the above query instead returns an error instructing the user to switch to `|> AGGREGATE` to perform the sum operation instead.

### Why are the changes needed?

The documented behavior of `|> SELECT` is that the expression list must not contain any aggregate functions, and the user receives an error otherwise.

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

Yes, see above.

### How was this patch tested?

This PR adds golden file based test coverage.

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

No.

Closes #50352 from dtenedor/fix-pipe-select-agg-bug.

Authored-by: Daniel Tenedorio <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 1ede242)
Signed-off-by: Wenchen Fan <[email protected]>
SauronShepherd pushed a commit to SauronShepherd/spark that referenced this pull request Mar 25, 2025
…ions in |> SELECT

### What changes were proposed in this pull request?

This PR fixes a small bug with `|> SELECT` with aggregate functions without aliases. In such cases, we should be returning an error instructing the user to use `|> AGGREGATE` instead, but we do not.

This bug only happens when the aggregate function does not have any alias.

For example:

```
VALUES (0), (1) tab(col)
|> SELECT SUM(col)
```

Before this PR, the above query returned a result of 1. After this PR, the above query instead returns an error instructing the user to switch to `|> AGGREGATE` to perform the sum operation instead.

### Why are the changes needed?

The documented behavior of `|> SELECT` is that the expression list must not contain any aggregate functions, and the user receives an error otherwise.

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

Yes, see above.

### How was this patch tested?

This PR adds golden file based test coverage.

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

No.

Closes apache#50352 from dtenedor/fix-pipe-select-agg-bug.

Authored-by: Daniel Tenedorio <[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