Opened 6 years ago

Closed 16 months ago

Last modified 2 months ago

#29850 closed New feature (fixed)

Add window support for RowRange frames

Reported by: Daniel Fuchs Owned by: Sarah Boyce
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: GSoC
Cc: Raphael Michel, Mads Jensen, John Speno Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no
Pull Requests:18935 merged, 17401 unmerged, 17423 merged, 17422 merged

Description (last modified by Mariusz Felisiak)

The current RowRange frame is missing handling for several cases.

None of the following are currently supported:
RowRange(start=-2, end=-1)
ROWS BETWEEN 2 PRECEDING AND 1 PRECEDING
RowRange(start=1, end=2)
ROWS BETWEEN 1 FOLLOWING AND 2 FOLLOWING

It's also missing support for EXCLUDE.
ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING EXCLUDE CURRENT ROW


Frame exclusion is supported in PostgreSQL 11+, SQLite 3.28+, and Oracle 21c+ other databases do not support exclusion (MariaDB doc, and MySQL doc).

Change History (18)

comment:1 by Tim Graham, 6 years ago

Summary: Poor Window Support for RowRange FramesAdd window support for RowRange frames
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

comment:3 by Mariusz Felisiak, 6 years ago

Description: modified (diff)
Version: 2.1master

comment:5 by Mariusz Felisiak, 5 years ago

Description: modified (diff)

Exclusion is supported also on SQLite 3.28+ (see release notes).

comment:6 by Mariusz Felisiak, 4 years ago

Keywords: GSoC added

comment:7 by Manav Agarwal, 4 years ago

Is it a good idea to add an argument named as exclude in WindowFrame class in django.db.models.expressions? This argument will contain the F() value of the row/range to be excluded.

comment:8 by Mariusz Felisiak, 3 years ago

Cc: Raphael Michel Mads Jensen added

comment:9 by John Speno, 3 years ago

Cc: John Speno added

comment:10 by Mariusz Felisiak, 2 years ago

Description: modified (diff)

comment:11 by Sarah Boyce, 16 months ago

Owner: changed from nobody to Sarah Boyce
Status: newassigned

comment:12 by Sarah Boyce, 16 months ago

Has patch: set

comment:13 by Sarah Boyce, 16 months ago

Patch needs improvement: set

Frame exclusions can be one of:

  • EXCLUDE CURRENT ROW
  • EXCLUDE GROUP
  • EXCLUDE TIES
  • EXCLUDE NO OTHERS

Marking that patch needs improvement as will aim to provide support for all types

comment:14 by Sarah Boyce, 16 months ago

Patch needs improvement: unset

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 16 months ago

In 6375cee:

Refs #29850 -- Added RowRange support for positive integer start and negative integer end.

comment:16 by Mariusz Felisiak, 16 months ago

Triage Stage: AcceptedReady for checkin

comment:17 by Mariusz Felisiak <felisiak.mariusz@…>, 16 months ago

In e4d012c:

Refs #29850 -- Added exclusion support to window frames.

comment:18 by Mariusz Felisiak, 16 months ago

Resolution: fixed
Status: assignedclosed

comment:19 by Sarah Boyce <42296566+sarahboyce@…>, 2 months ago

In 94436de:

Refs #29850 -- Removed obsolete test_window_frame_raise_not_supported_error.

This NotSupportedError was removed in 6375cee490725969b4f67b3c988ef01350c1ad6d
because it will never be reached due to the same exception raised by
Window.as_sql().

comment:20 by Sarah Boyce <42296566+sarahboyce@…>, 2 months ago

In 6f42b67:

[5.1.x] Refs #29850 -- Removed obsolete test_window_frame_raise_not_supported_error.

This NotSupportedError was removed in 6375cee490725969b4f67b3c988ef01350c1ad6d
because it will never be reached due to the same exception raised by
Window.as_sql().

Backport of 94436dee57ce677e6ffcbb0438e0441d5c261d62 from main.

Note: See TracTickets for help on using tickets.
Back to Top