Uh oh!
There was an error while loading. Please reload this page.
Fix jobs table generation for uuid FK-derived primary keys (#1515) - #1518
Conversation
Job._generate_definition() emitted attr.type (the backend-resolved SQL type, e.g. binary(16) for a uuid attribute) into a fresh DataJoint definition string. That resolved type is not valid DataJoint definition syntax, so declaring the ~~jobs table raised 'Unsupported attribute type binary(16)' on the first .jobs access (including inside populate(reserve_jobs=True)), and never recovered. Use attr.original_type (the DataJoint-level alias, e.g. uuid) with a fallback to attr.type, mirroring the fallback DataJoint already uses in heading.py. This makes jobs-table generation correct for every core-type alias in an FK-derived primary key (uuid, float32, ...), not just uuid. Adds a regression test: a Computed table whose primary key is FK-derived from a uuid attribute.
There was a problem hiding this comment.
LGTM.
Small strengthening: the fix mirrors the same original_type or type fallback in TWO existing sites — heading.py:543 AND table.py:1327 (inside Table.describe). Worth mentioning the second precedent in the PR body — reinforces "jobs.py was the outlier missing the pattern" rather than "one-off similarity".
Optional hardening: test uses uuid only, but the fix generalizes to any core-type alias. A parameterized second case (e.g., decimal(6,3) PK) would catch a hypothetical mis-regression like if original_type == "uuid": ... else: attr.type. Non-blocking — the fix generalizes by construction (the or short-circuit applies to any attribute whose original_type is set).
Fixes#1515.
Problem
Accessing
.jobson aComputed/Importedtable whose primary key is FK-derived from auuidattribute crashed with:This fires on the first
.jobsaccess for such a table — including the implicit access insidepopulate(reserve_jobs=True)— and never recovers, since the~~jobstable stays undeclared. It disablesreserve_jobs=Trueentirely for the common, recommended pattern of usinguuidroot keys with downstream computed tables.Root cause
Job._generate_definition()builds the~~jobstable's DataJoint definition string from the target's FK-derived primary key. For each attribute it emittedattr.type— the backend-resolved SQL type (binary(16)for auuid) — rather than the DataJoint-level alias the user wrote (uuid).binary(16)is not valid DataJoint definition syntax, so whenJob.declare()re-parsed the generated string,match_type("binary(16)")matched no pattern and raised.Fix
Use
attr.original_type or attr.typein_get_fk_derived_pk_attrs, mirroring the fallback DataJoint already uses inheading.py(original_type = attr["original_type"] or attr["type"]).original_typeholds the DataJoint alias for core types (uuid,float32, …) and isNoneotherwise, so:uuidPK → definition lineitem : uuid(re-parses correctly; DataJoint resolves it back tobinary(16)internally).uuid.attr.typeas before).Test
Adds
test_jobs_table_uuid_fk_derived_pk(plus aBasicComputedtable in the uuid test schema: aComputedtable whose PK is FK-derived from auuidparent). It asserts the generated definition carriesuuid(notbinary(16)), that.jobs.refresh()declares the table, and that the PK attribute round-trips tooriginal_type == "uuid".