-
Notifications
You must be signed in to change notification settings - Fork 2
Analysis Nodes
For a quick overview of how the node filters work, see ASMR Poster
Nodes can return a dict of kwargs that are passed to Django queryset.annotate()
- this is so you can setup FilteredRelations etc, controlling how you join to another table (eg to restrict it to just 1 PostGres partition)
Nodes perform filtering by returning a Django Q object - these represent SQL operations, and can be combined easily via AND and OR operations.
Applying annotation/filters in different orders can cause multiple joins to the same table (even when using FilteredRelation) - so the node Qs are stored in a dictionary, with keys being the node annotation kwargs. There are applied in the order of annotation kwargs.
Chains of filters to a reverse foreign key relationship causes multiple joins, so use Q objects which are combined at the end
qs = qs.filter(table_1__val=1)
qs = qs.filter(table_2__val=2)
is not necessarily equal to:
qs.filter(table_1__val=1, table_2__val=2)