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

handling window frame selection in case of same bound kind #16231

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sreemanamala
Copy link
Contributor

@sreemanamala sreemanamala commented Apr 3, 2024

Description

This PR aims to handle the following cases in window frame selection

rows between unbounded preceding and x preceding
rows between x following and unbounded following
rows between x preceding and y preceding
rows between x following and y following


Key changed/added classes in this PR
  • DefaultFramedOnHeapAggregatable.java
  • DruidSqlValidator.java
  • Windowing.java

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.

@@ -187,7 +187,7 @@ public AggInterval next()
groupToRowIndex(relativeGroupId(1))
),
Interval.of(
groupToRowIndex(relativeGroupId(-lowerOffset)),
groupToRowIndex(relativeGroupId(lowerOffset < 0 ? lowerOffset : -lowerOffset)),
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't look right - this is effectively: -Math.abs(lowerOffset)
this part was already working with relative offsets ; so I think it should be simply relativeGroupId(lowerOffset) - didn't that worked?

int resultStorageIndex = 0;

// if the upper offset is -ve, then we need to ignore those many rows prior to the current row
int resultStorageIndex = -1 * Math.min(upperOffset, 0);
Copy link
Member

Choose a reason for hiding this comment

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

nit: why not use an unary - ?

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.

None yet

3 participants