Mayil-AI-Sandbox / kuzudb_jan15

MIT License
0 stars 0 forks source link

Disable setting the IRI of predicates in Relationship tables of RDFGraphs or make it behave correctly (hashtag2773) #32

Open vikramsubramanian opened 4 months ago

vikramsubramanian commented 4 months ago

I tried the following query in the UniKG example in the documentation:

MATCH (r:UniKG_r {iri:" 
WHERE p.iri =  " 
SET p.iri = " 
RETURN r.iri, p.iri, o.iri

This query is trying to set the IRI of the resource node. I got the following output:

--------------------------------------------------
| r.iri                          | p.iri | o.val |
--------------------------------------------------
|  |       | 60000 |
--------------------------------------------------

Which already is wrong. But it also did not have any effect, i.e., the IRI stayed the same:

MATCH (r:UniKG_r {iri:" 
WHERE p.iri =  " 
RETURN r.iri, p.iri, o.val;
-----------------------------------------------------------------------------
| r.iri                          | p.iri                            | o.val |
-----------------------------------------------------------------------------
|  |  | 60000 |
-----------------------------------------------------------------------------

The previous IRI is still there. And when I query for all triples, I don't see any triple of Waterloo with predicate

We should either disable setting iris of predicates or support this so that we implement the right behavior, which is: 1) add the predicate if needed to Resources table 2) set the IRI of the predicate relationship. )

mayil-ai[bot] commented 4 months ago

Summary: Issue with setting the IRI of predicates in Relationship tables of RDFGraphs in UniKG example.

Possible Solution

Based on the provided information, the issue is with setting the IRI of predicates in Relationship tables of RDFGraphs. The IRI of the resource node is not being set correctly. To address this issue, consider the following solution:

Here is a pseudo-code outline of the steps to take in the bind_graph_pattern.cpp file:

if (!resourceTableIDs.empty()) {
    // ... existing code ...

    // Check if the IRI exists in the Resources table
    auto iriID = checkAndAddIRIToResourcesTable(iri);

    // Set the IRI of the predicate relationship
    setProperty(queryRel, rdf::IRI, iriID);

    // ... existing code ...
}

And in the setProperty function:

void setProperty(Entity entity, String propertyKey, String propertyValue) {
    if (propertyKey.equals(rdf::IRI)) {
        // Logic to set the IRI property, referencing the Resources table
    } else {
        // Existing logic for other properties
    }
}

Make sure to test the changes thoroughly to ensure that the IRI is being set correctly and that the expected behavior is achieved.

Code snippets to check