1

I am a researcher in Loren Frank's lab at UCSF. When calling populate on a Computed datajoint table that depends on two upstream tables which have entries that have the same value for shared primary attributes but different values for a shared secondary attribute ("analysis_file_name"), I get the following error:

~/anaconda3/envs/nwb_datajoint/lib/python3.8/site-packages/datajoint/condition.py in assert_join_compatibility(expr1, expr2)
     63     if not isinstance(expr1, U) and not isinstance(expr2, U):  # dj.U is always compatible
     64         try:
---> 65             raise DataJointError(
     66                 "Cannot join query expressions on dependent attribute `%s`" % next(
     67                     r for r in set(expr1.heading.secondary_attributes).intersection(

DataJointError: Cannot join query expressions on dependent attribute `analysis_file_name`

To make clear why this situation is arising, our lab currently has a workflow where all datajoint tables that store data in nwb files have the secondary attribute "analysis_file_name", which contains the name of the analysis file storing the data. Consequently, entries across two tables can share values at primary attributes, but differ in the value at the secondary attribute "analysis_file_name". The above error seems to arise when "joining" two such tables, e.g. during the autopopulation of a third table that depends on those tables. Could folks from datajoint clarify whether to join two tables (e.g. during autopopulation of a third table that depends on those tables), it must be the case that entries which have the same value at shared primary attributes also have the same value at shared secondary attributes? Thanks for any clarification on this.

jguides
  • 27
  • 4

1 Answers1

1

This is indeed a bug and I filed it here: issue 980

We are working on the solution PR981

The problem is that the key_source did not project out the secondary attributes before joining.

In the meantime, the workaround is to override the key_source attribute projecting out the secondary attributes in one of the tables. For example, if the two parents are A and B then you need to define the method:

@property
def key_source(self):
    return A.proj() * B