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

feat: window function calcite support #172

Merged
merged 9 commits into from
Sep 1, 2023

Conversation

vbarua
Copy link
Member

@vbarua vbarua commented Aug 30, 2023

feat: support for window bounds type

BREAKING CHANGE:

  • windowFunction expression creator now requires window bound type param
  • the WindowBound POJO representation has been reworked to use visitation and more closely match the spec
  • ExpressionRexConvert now requires a WindowFunctionConverter

enum Direction {
PRECEDING,
FOLLOWING
R visit(Unbounded unbounded);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Direction doesn't have an equivalent in the Substrait spec itself. Calcite has a concept of UNBOUNDED_PRECEDING and UNBOUNDED_FOLLOWING, but those can be reduced to singular Unbounded WindowBound when converting from Calcite to Pojo.

@@ -5,58 +5,62 @@
@Value.Enclosing
public interface WindowBound {
Copy link
Member Author

Choose a reason for hiding this comment

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

Rather than encoding the WindowBound type using a combination of BoundedKind and Direction, I've switched this to 4 classes:

  1. Preceding
  2. Following
  3. Current
  4. Unbounded

and introduced a WindowBoundVisitor to handle dispatch when converting from these to various other representations.

This representation of Window Bounds:

  1. More closely matches the spec.
  2. Reduces the need for casting of WindowBound interfaces to concrete types.
  3. Reduces cognitive complexity (in my opinion) as users no longer need to reason about 6 different enum combinations (3 bounded kinds * 2 directions), and instead have 4 concrete classes.

@vbarua vbarua force-pushed the vbarua/window-function-calcite-support branch from 469e51b to bf91fe4 Compare August 30, 2023 19:59
@vbarua vbarua marked this pull request as ready for review August 30, 2023 20:09
@vbarua vbarua merged commit 7618bb8 into main Sep 1, 2023
8 checks passed
@vbarua vbarua deleted the vbarua/window-function-calcite-support branch September 1, 2023 21:05
vbarua added a commit that referenced this pull request Sep 6, 2023
feat: support for window bounds type
feat: reject IGNORE NULLS

BREAKING CHANGE:
* windowFunction expression creator now requires window bound type parameter
* the WindowBound POJO representation has been reworked to use visitation and more closely match the spec
* ExpressionRexConverter now requires a WindowFunctionConverter
ajegou pushed a commit to ajegou/substrait-java that referenced this pull request Mar 29, 2024
…rait-io#172)

feat: support for window bounds type
feat: reject IGNORE NULLS

BREAKING CHANGE:
* windowFunction expression creator now requires window bound type parameter
* the WindowBound POJO representation has been reworked to use visitation and more closely match the spec
* ExpressionRexConverter now requires a WindowFunctionConverter
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.

2 participants