fluree / db

Fluree database library
https://fluree.github.io/db/
Other
334 stars 21 forks source link

error querying for rdf:type with "larger" transaction #458

Open jakep36 opened 1 year ago

jakep36 commented 1 year ago

I've attached a Postman collection with this.

After creating the db, transacting the SHACL and transacting the smaller data transaction the query for rdf:type ex:Movie works as expected.

After creating the db, transacting the SHACL and transacting the larger data transaction the query for rdf:type ex:Movie does not work as expected.

It gives an error in the results of:

"data": {
            "status": 400,
            "error": "db/invalid-query"
        },
        "message": "Undefined RDF type specified: https://example.com/Movie",
        "suppressed": [],
        "localizedMessage": "Undefined RDF type specified: https://example.com/Movie"
    }

But you can query the data by something else like one of the predicate names and it does show results like the two query in the multi-query.

large transaction issue.postman_collection.json.zip

haliechm commented 1 year ago

large_txn_issue.zip

Here is the same zip with a few modifications

The main change is that I initially supplied the incorrect SHACL rules above... this is the cause of the error posted ( "Undefined RDF type specified: https://example.com/Movie")

With the new SHACL rules supplied, no error is thrown when running the query on the large dataset. However, the query comes back with an empty list instead. Oddly enough, the data does seem to be in the ledger (ie there are instances of type "ex:Movie" that can be queried for)

dpetran commented 1 year ago

I took a look at this yesterday, here's what I found:

  1. there wasn't a request for creating a second "large" ledger, so I just transacted everything into the "ledgerTestSmall" ledger
  2. the "transact large" request failed, for multiple reasons. The first was a bug concerning how we were validating "sh:class" constraints. The second was just a validation error - we were passing integers in where the shacl schema was expecting floats. Adding this @context to the request fixed it:
    "@context": {
            "https://example.com/population": {
                "@type": "xsd:float"
            },
            "https://example.com/area": {
                "@type": "xsd:float"
            },
            "https://example.com/runtime": {
                "@type": "xsd:float"
            },
            "https://example.com/budget": {
                "@type": "xsd:float"
            },
            "https://example.com/revenue": {
                "@type": "xsd:float"
            },
            "https://example.com/rating": {
                "@type": "xsd:float"
            }
        },
  3. The queries work fine now.
dpetran commented 1 year ago

Fix for the bug in https://github.com/fluree/db/pull/501