Skip to content

Commit 3baa07a

Browse files
committed
Use keep_all_rows instead of left for aggregation
The existing DataJoint API uses keep_all_rows=True which is more intuitive and self-documenting than left=True.
1 parent 5432141 commit 3baa07a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/SPEC-semantic-matching.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ For `A.aggr(B, ...)`, semantic matching applies with an additional constraint.
150150

151151
This ensures that each B tuple belongs to exactly one A entity, so aggregation groups are non-overlapping. If B is missing any part of A's primary key, a B tuple could match multiple A tuples and be counted in multiple aggregates.
152152

153-
**Left join aggregation**: The same constraint applies when using `A.aggr(B, ..., left=True)`. The left join allows A tuples with no matching B tuples to appear in the result (with NULL aggregates), but the grouping constraint remains: B must contain A's complete primary key.
153+
**Keep all rows**: The same constraint applies when using `A.aggr(B, ..., keep_all_rows=True)`. This keeps all A tuples in the result even if they have no matching B tuples (with NULL aggregates), but the grouping constraint remains: B must contain A's complete primary key.
154154

155155
**Example**:
156156
```python
@@ -694,7 +694,7 @@ WHERE c.contype = 'f'
694694

695695
**Rationale**: This ensures non-overlapping aggregation groups. Each B tuple belongs to exactly one A entity, preventing double-counting.
696696

697-
**Left join**: The same constraint applies for `A.aggr(B, ..., left=True)`. A tuples with no matching B tuples appear with NULL aggregates, but the grouping constraint remains.
697+
**Keep all rows**: The same constraint applies for `A.aggr(B, ..., keep_all_rows=True)`. A tuples with no matching B tuples appear with NULL aggregates, but the grouping constraint remains.
698698

699699
## Testing Strategy
700700

@@ -741,7 +741,7 @@ Semantic matching is a significant change to DataJoint's join semantics that imp
741741
| **D6**: `@` operator | Deprecated - use `.join(semantic_check=False)` |
742742
| **D7**: Migration | Utility function + automatic fallback computation |
743743
| **D8**: PK formation | Functional dependency analysis; left operand wins ties; non-commutative |
744-
| **D9**: Aggregation | B must contain A's entire PK; result PK = PK(A); applies to left join too |
744+
| **D9**: Aggregation | B must contain A's entire PK; result PK = PK(A); applies to `keep_all_rows=True` too |
745745

746746
### Compatibility
747747

0 commit comments

Comments
 (0)