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-41778][SQL] Add an alias "reduce" to ArrayAggregate #39297

Closed
wants to merge 3 commits into from

Conversation

ueshin
Copy link
Member

@ueshin ueshin commented Dec 29, 2022

What changes were proposed in this pull request?

Adds an alias "reduce" to ArrayAggregate.

Also modified the higher-order functions to also copy tags when binding to propagate them properly.

Why are the changes needed?

Presto provides the function: https://prestodb.io/docs/current/functions/array.html#reduce.

Does this PR introduce any user-facing change?

Yes, a new alias for ArrayAggregate.

For example:

SELECT reduce(array(1, 2, 3), 0, (acc, x) -> acc + x);
SELECT reduce(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);

as the same as "aggregate":

SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x);
SELECT aggregate(array(1, 2, 3), 0, (acc, x) -> acc + x, acc -> acc * 10);

How was this patch tested?

Added/modified tests.

@github-actions github-actions bot added the SQL label Dec 29, 2022
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

@dongjoon-hyun
Copy link
Member

Merged to master for Apache Spark 3.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants