Skip to content

Comments

Allow Type in agg function metadata constructors#21316

Merged
tdcmeehan merged 1 commit intoprestodb:masterfrom
ZacBlanco:upstream-parametric-agg-types
Nov 8, 2023
Merged

Allow Type in agg function metadata constructors#21316
tdcmeehan merged 1 commit intoprestodb:masterfrom
ZacBlanco:upstream-parametric-agg-types

Conversation

@ZacBlanco
Copy link
Contributor

@ZacBlanco ZacBlanco commented Nov 6, 2023

Description

This change introduces the ability to allow the AccumulatorStateMetadata classes, AccumulatorStateSerializer and AccumulatorStateFactory, to add Type parameters to their constructor with proper @typeparameter annotations. This should allow most new parametric aggregation functions to be implemented using annotations rather than manually extending SqlAggregationFunction

Motivation and Context

One of the main downsides to the previous implementation is that parametric aggregations with defined type parameters couldn't be easily specialized as their serialization and deserialization functions usually relied upon knowing the type parameters. Thus, many of the parametric aggregation functions presto codebase don't use the @AggregationFunction and associated annotations which makes the code more complex and hard to maintain.

Impact

N/A

Test Plan

A few additional unit tests

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

== NO RELEASE NOTE ==

@ZacBlanco ZacBlanco requested a review from a team as a code owner November 6, 2023 17:06
@ZacBlanco ZacBlanco requested a review from presto-oss November 6, 2023 17:06
@ZacBlanco
Copy link
Contributor Author

cc: @tdcmeehan

@ZacBlanco
Copy link
Contributor Author

ZacBlanco commented Nov 6, 2023

If this gets merged I can simplify the function implementations in #20937 and #21296

@tdcmeehan tdcmeehan self-assigned this Nov 6, 2023
@ZacBlanco ZacBlanco force-pushed the upstream-parametric-agg-types branch 2 times, most recently from 758697f to 61fa73e Compare November 6, 2023 19:58
Copy link
Contributor

@tdcmeehan tdcmeehan left a comment

Choose a reason for hiding this comment

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

LGTM--CC: @kaikalur, do you want to have a look too?

@ZacBlanco ZacBlanco force-pushed the upstream-parametric-agg-types branch 2 times, most recently from 70b0ce5 to be32b1c Compare November 7, 2023 00:17
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: let's keep indentation consistent

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 was inserted by the IntelliJ code formatter using Presto's official codestyle XML config, so I believe it was not conforming to the code style previously? Checkstyle may be missing a rule.

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 changes makes some improvements to the annotation parsing for
aggregation functions. One of the main downsides to the previous
implementation is that parametric aggregations with defined type parameters
couldn't be easily specialized as their serialization and deserialization functions
usually relied upon knowing the type parameters. Thus, many of the
parametric aggregation functions presto codebase  don't use the
@AggregationFunction and associated  annotations which makes the code
more complex and hard to maintain.

We introduce the ability to allow the AccumulatorStateMetadata
classes, AccumulatorStateSerializer and AccumulatorStateFactory, to
add `Type` parameters to their constructor with proper @typeparameter
annotations. This should allow any new parametric aggregation functions
to be implemented using annotations rather than manually extending
BuiltInSqlFunction
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