Skip to content

Commit 8441793

Browse files
Clarify that aggregation attributes can be primary or secondary in B
In A.aggr(B), B must have all of A's primary key attributes, but these can be either primary or secondary attributes in B. Co-authored-by: dimitri-yatsenko <dimitri@datajoint.com>
1 parent d68de16 commit 8441793

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

docs/src/design/semantic-matching-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ In `A.aggr(B, ...)`, entries from B are grouped by A's primary key and aggregate
442442

443443
**Functional Dependency Requirement**: Every entry in B must match exactly one entry in A. This requires:
444444

445-
1. **B must have all of A's primary key attributes**: If A's primary key is `(a, b)`, then B must contain attributes named `a` and `b`.
445+
1. **B must have all of A's primary key attributes**: If A's primary key is `(a, b)`, then B must contain attributes named `a` and `b`. These attributes can be either primary or secondary in B.
446446

447-
2. **Primary key attributes must be homologous**: The namesake attributes in B must have the same lineage as in A. This ensures they represent the same entity.
447+
2. **These attributes must be homologous**: The namesake attributes in B must have the same lineage as in A. This ensures they represent the same entity.
448448

449449
```python
450450
# Valid: Session.aggr(Trial, ...) where Trial has session_id from Session

src/datajoint/expression.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@ def aggr(self, group, *attributes, keep_all_rows=False, **named_attributes):
469469
In A.aggr(B, ...), groups entries from B by the primary key of A and computes
470470
aggregate functions. Requires functional dependency: every entry in B must match
471471
exactly one entry in A. This means B must have all of A's primary key attributes
472-
as homologous namesakes (same name AND same lineage).
472+
as homologous namesakes (same name AND same lineage). These attributes can be
473+
either primary or secondary in B.
473474
474475
:param group: the query expression to aggregate (B in A.aggr(B))
475476
:param attributes: attributes from self to include in the result
@@ -643,7 +644,8 @@ def create(cls, arg, group, keep_all_rows=False):
643644
644645
For A.aggr(B, ...), ensures functional dependency: every entry in B must match
645646
exactly one entry in A. This requires B to have all of A's primary key attributes
646-
as homologous namesakes (same name AND same lineage).
647+
as homologous namesakes (same name AND same lineage). These attributes can be
648+
either primary or secondary in B.
647649
648650
:param arg: the grouping expression (A in A.aggr(B))
649651
:param group: the expression to aggregate (B in A.aggr(B))

0 commit comments

Comments
 (0)