Skip to content

Support Framing for Window Aggregations - #13514

Merged
cheddar merged 4 commits into
apache:masterfrom
imply-cheddar:row-framing-on-windows
Dec 15, 2022
Merged

cheddar merged 4 commits into
apache:masterfrom
imply-cheddar:row-framing-on-windows

Conversation

@imply-cheddar

Copy link
Copy Markdown
Contributor

This adds support for framing over ROWS for window aggregations.

Still not implemented as yet:

  1. RANGE frames
  2. Multiple different frames in the same query
  3. Frames on last/first functions

This PR also brings with it some adjustments and improvements to the tests for semantic interfaces and RowsAndColumns implementations.

The PR touches a lot of files, that's mostly because I combined all of the "semantic interfaces" into a semantic package and that affected a bunch of imports.

The PR also looks like it's a lot of lines of code, but most of that is actually whitespace changes on some of the test files done by auto-formatting. Checking them in now so that future auto-formatting is safe from generating whitespace changes.

The primary code to review is essentially all inside of FramedOnHeapAggregatable, the tests associated with it and some in the planning.

Lastly, there are some code cleanup/renames being included that were asked for in the previous PR. (Things like completing the renaming of cell and removing the TODOs)

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@lgtm-com

lgtm-com Bot commented Dec 7, 2022

Copy link
Copy Markdown

This pull request fixes 1 alert when merging f27a86d into 83261f9 - view on LGTM.com

fixed alerts:

  • 1 for Boxed variable is never null

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@lgtm-com

lgtm-com Bot commented Dec 7, 2022

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 9870923 into 9679f6a - view on LGTM.com

fixed alerts:

  • 1 for Boxed variable is never null

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@lgtm-com

lgtm-com Bot commented Dec 7, 2022

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 7f38000 into b56855b - view on LGTM.com

fixed alerts:

  • 1 for Boxed variable is never null

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@lgtm-com

lgtm-com Bot commented Dec 8, 2022

Copy link
Copy Markdown

This pull request fixes 1 alert when merging c5f32b0 into b56855b - view on LGTM.com

fixed alerts:

  • 1 for Boxed variable is never null

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

This adds support for framing  over ROWS
for window aggregations.

Still not implemented as yet:
1. RANGE frames
2. Multiple different frames in the same query
3. Frames on last/first functions

@clintropolis clintropolis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

public class WindowFrame
{
@SuppressWarnings("unused")
public enum PeerType

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is worth a javadoc, it is described in some other places, such as FramedOnHeapAggregatable, but here would be nice too probably, is fine to defer until later when we have more support for this stuff though too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, word. This is a SQL concept stolen from... SQL, so I didn't think to document it as much as I probably should have. When we add support for RANGE peers, we can remove the suppression and actually document it.


import java.util.Objects;

public class WindowFrame

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

heh, its a shame that "frame" really is the best name this; hopefully it wont be too confusing since it doesn't really have anything to do with the other one, https://github.com/apache/druid/blob/master/processing/src/main/java/org/apache/druid/frame/Frame.java which should maybe be called DataFrame or... idk naming is just the worst 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

DataFrame is a thing in R too... I don't think it's far from what a org.apache.druid.frame.Frame is though, so maybe that's actually a good name?

Comment on lines +75 to +77
// In this case, there are not enough rows to completely build up the full window aperture before it needs to
// also start contracting the aperture because of the upper offset. So we use a method that specifically
// handles checks for both expanding and reducing the aperture on every iteration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just wanted to say thanks for all the comments in this class, a lot going on here and it helps out 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

little secret: I needed them for myself :P

some code is "self documenting" some code is not, this code is not.

@cheddar
cheddar merged commit 089d8da into apache:master Dec 15, 2022
@clintropolis clintropolis added this to the 26.0 milestone Apr 10, 2023
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
* Support Framing for Window Aggregations

This adds support for framing  over ROWS
for window aggregations.

Still not implemented as yet:
1. RANGE frames
2. Multiple different frames in the same query
3. Frames on last/first functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants