1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #28333 -- Added partial support for filtering against window functions.

Adds support for joint predicates against window annotations through
subquery wrapping while maintaining errors for disjointed filter
attempts.

The "qualify" wording was used to refer to predicates against window
annotations as it's the name of a specialized Snowflake extension to
SQL that is to window functions what HAVING is to aggregates.

While not complete the implementation should cover most of the common
use cases for filtering against window functions without requiring
the complex subquery pushdown and predicate re-aliasing machinery to
deal with disjointed predicates against columns, aggregates, and window
functions.

A complete disjointed filtering implementation should likely be
deferred until proper QUALIFY support lands or the ORM gains a proper
subquery pushdown interface.
This commit is contained in:
Simon Charette
2022-08-10 08:22:01 -04:00
committed by Mariusz Felisiak
parent f3f9d03edf
commit f387d024fc
9 changed files with 489 additions and 67 deletions

View File

@@ -17,6 +17,13 @@ class Employee(models.Model):
bonus = models.DecimalField(decimal_places=2, max_digits=15, null=True)
class PastEmployeeDepartment(models.Model):
employee = models.ForeignKey(
Employee, related_name="past_departments", on_delete=models.CASCADE
)
department = models.CharField(max_length=40, blank=False, null=False)
class Detail(models.Model):
value = models.JSONField()