schema.rebuild_lineage() fails on PostgreSQL, after emptying ~lineage
Maintainer antworten meist innerhalb von 4 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Start in lineage.py at rebuild_schema_lineage and compare its information_schema queries with the adapters’ load_primary_keys_sql and load_foreign_keys_sql used by Dependencies.load. Reproduce on PostgreSQL 15 with the supplied schema and check how the function handles ~lineage when rebuilding fails. Done means lineage rebuilding works on PostgreSQL and MySQL, and a failure does not leave ~lineage empty.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
schema.rebuild_lineage() fails on PostgreSQL. rebuild_schema_lineage (lineage.py) reads keys from information_schema with MySQL-only names:
- foreign keys from
KEY_COLUMN_USAGE.REFERENCED_TABLE_SCHEMA,REFERENCED_TABLE_NAMEandREFERENCED_COLUMN_NAME, columns PostgreSQL does not have; - primary keys by
CONSTRAINT_NAME = 'PRIMARY', while PostgreSQL names a primary-key constraint<table>_pkey.
The foreign-key query raises, so the rebuild stops before writing anything. It has already run DELETE FROM ~lineage by then, so the call leaves the schema with an empty ~lineage table: every join on the schema's tables is then refused, until each table is decorated again and its rows are refilled.
The docs and several messages recommend schema.rebuild_lineage() as the repair for lineage problems, and dj.migrate.rebuild_lineage calls the same function.
Reproduction
DataJoint master, PostgreSQL 15:
import datajoint as dj
schema = dj.Schema("scratch_rebuild_lineage")
@schema
class Image(dj.Manual):
definition = """
image_id : int32
"""
schema.rebuild_lineage()
# UnknownAttributeError: column "referenced_table_schema" does not exist
# ~lineage held 1 row before the call and 0 after it
Expected behavior
rebuild_lineage() works on both backends. It could read primary and foreign keys through the adapters' existing load_primary_keys_sql and load_foreign_keys_sql, as Dependencies.load does, and leave ~lineage unchanged if it fails.
- Vorherrschende Sprache
- Python
- Sterne
- 197
- Forks
- 101
- Ø Merge
- 3 T. 8 Std.
- Gemergte PRs (30 T.)
- 28
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus datajoint/datajoint-python
-
len() of an expression with an empty primary key generates invalid SQLEvtl. vergeben @dimitri-yatsenko hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
datajoint/datajoint-python#1581 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
dj.Diagram theme: make the font configurableEvtl. vergeben @dimitri-yatsenko hat das vor 5 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
datajoint/datajoint-python#1539 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
enhancement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
datajoint/datajoint-python#1644 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
A join on namesake secondary attributes raises the stale-`~lineage` error on a freshly declared schemaEvtl. vergeben @dimitri-yatsenko hat das vor 5 Tagen übernommen. Offenbug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 82/100
datajoint/datajoint-python#1640 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticksEvtl. vergeben @mayuriphad hat das vor 5 Tagen übernommen. Offenbug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 75/100
datajoint/datajoint-python#1638 ·
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in datajoint/datajoint-python
Ähnliche Issues
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
NCAR/miles-credit#526 ·
-
documentation
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 76/100
conda/conda-lock#957 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Type: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
aws-samples/sample-per-model-bedrock#464 ·
Maintainer antworten meist innerhalb von 1 Tag