Mayil-AI-Sandbox / kuzudb_jan15

MIT License
0 stars 0 forks source link

Dropping an RDFGraph when there is a non-RDFGraph rel table leaves the rel table "dangling" (hashtag2752) #40

Open vikramsubramanian opened 4 months ago

vikramsubramanian commented 4 months ago

Consider an RDFGraph UniKG and another node table Students and a rel table SameAs from Students to UniKG_r. You can drop UniKG even if that would leave Students around. Normally this would give a Binder exception that says: "Cannot delete node table nodeTableX referenced by rel table relTableY."

To replicate:

kuzu> CREATE RDF Graph UniKG;
kuzu> CREATE NODE TABLE Students(name STRING, primary key (name));
kuzu> CREATE REL TABLE SameStudent(FROM Students TO UniKG_r);
kuzu> DROP TABLE UniKG;
kuzu>  MATCH (a:Students)-[s:SameStudent]->(b) RETURN *;
Error: unordered_map::at: key not found

Normally, this would happen:

kuzu> CREATE NODE TABLE nodeTable1 (name STRING, primary key (name));
kuzu> CREATE NODE TABLE nodeTable2 (name STRING, primary key (name));
kuzu> CREATE REL TABLE relTable (FROM nodeTable1 TO nodeTable2);
kuzu> DROP TABLE nodeTable2;
Error: Binder exception: Cannot delete node table nodeTable2 referenced by rel table relTable.

So the system does not allow dropping nodeTable2. )

mayil-ai[bot] commented 4 months ago

Summary: Dropping an RDFGraph when there is a non-RDFGraph rel table leaves the rel table "dangling" causing an error.

Possible Solution

Based on the provided information and code snippets, the issue seems to be related to the deletion of an RDFGraph which leaves a non-RDFGraph relationship table (rel table) dangling, causing an error during a MATCH query after the RDFGraph is dropped. The expected behavior is to prevent the drop with a Binder exception if there are dependencies.

To resolve the issue, the following steps should be taken:

By implementing these changes, the software should correctly handle the deletion of RDFGraphs and maintain the integrity of the relationships within the database.

Code snippets to check