Skip to content

Operators Join @ and Restrict ^ with permissive join-compatibility checks. #785

@dimitri-yatsenko

Description

@dimitri-yatsenko

DataJoint has a set of rules for join compatibility. Joins can be performed on attributes that are semantically compatible.

The present rule is:

All the namesake attributes in both operands must be in the primary key of either of the operands.

The rule itself is likely to evolve before the 1.0 release.

An attempt to join two expressions that are not join compatible results in an error. The join compatibility are also applies when restricting one expression with another expression.

In rare cases, users wish to override this restriction and allow joining on attributes that DataJoint deems incompatible. Under the current rule, this can be accomplished by promoting an attribute to be included in the primary key, making it compatible with any namesake attribute in the other operand. This technique will no longer generally work if the join-compatibility rule changes.

Therefore, we propose to add two new operators @ and ^ that work identically to * and & but ignore the join-compatibility check.

Join

A * B   # raises an error if A and B are not join-compatible
A @ B  # joins anyway

Restriction

A & B  # raises an error if A and B are not join-compatible 
A ^ B   # restricts anyway

Anti-restriction

A - B  # raises an error if A and B are not join-compatible 
A & -B  # raises an error if A and B are not join-compatible 
A ^ -B   # anti-restricts anyway

Aggregation

Aggregation will have an extra keyword argument, permissive_join=False

A.aggr(B,  ...)   # raises an error if A and B are not join-compatible
A.aggr(B, ..., permissive_join=True)   # aggregates anyway

Universal sets

Universal sets are join-compatible with anything

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions