1

I've been having issues with SPARQL insert/delete statements in my GraphDB database. I believe my queries are correct and they generally work. However, occasionally they inexplicably fail. The data seemingly becomes "locked" and immune to change via insert/delete query. I'm re-running the same insert/delete queries as more data are added to my database. Once an insert/delete query fails, the only way I can "fix" the database is to rebuild it entirely from scratch by re-ingesting turtle files. I'd really like to figure out this problem and find a solution. Below I've included two demo queries with identical where clause. Note that this particular insert/delete query has never worked, but I believe it should be functional.

Insert/delete query fails. "The number of statements did not change. Update took 0.9s."

PREFIX onto: <http://www.ontotext.com/>
PREFIX f: <https://redacted.org/term/>

# correct strain names

DELETE {
  ?sid f:strain_name ?strain_name .
  ?sid f:gisaid_strain_name ?gisaid_strain_name .
}
INSERT {
  ?gid f:strain_name ?fix_strain_name .
  ?gid f:gisaid_strain_name ?fix_gisaid_strain_name .
}
WHERE {
  ?sid f:strain_name ?strain_name .
  ?sid f:gisaid_strain_name ?gisaid_strain_name .

  BIND (REPLACE(?strain_name, "(A/swine/[^/]+/).+(A0.*)", "$1$2") AS ?fix_strain_name)
  BIND (REPLACE(?gisaid_strain_name, "(A/swine/[^/]+/).+(A0.*)", "$1$2") AS ?fix_gisaid_strain_name)

  FILTER REGEX(?strain_name, "A/swine/[^/]+/.+[^A-Za-z0-9]A0[0-9]{6,8}/.*") .
}

Select query shows hundreds of values that need to be corrected. Showing results from 1 to 987 of 987. Query took 1s.

PREFIX onto: <http://www.ontotext.com/>
PREFIX f: <https://redacted.org/term/>

# correct strain names

SELECT
  ?strain_name
  ?fix_strain_name
  ?gisaid_strain_name
  ?fix_gisaid_strain_name
FROM onto:disable-sameAs
WHERE {
  ?sid f:strain_name ?strain_name .
  ?sid f:gisaid_strain_name ?gisaid_strain_name .

  BIND (REPLACE(?strain_name, "(A/swine/[^/]+/).+(A0.*)", "$1$2") AS ?fix_strain_name)
  BIND (REPLACE(?gisaid_strain_name, "(A/swine/[^/]+/).+(A0.*)", "$1$2") AS ?fix_gisaid_strain_name)

  FILTER REGEX(?strain_name, "A/swine/[^/]+/.+[^A-Za-z0-9]A0[0-9]{6,8}/.*") .
}

Please let me know if I can provide additional information to help solve this problem. I'm fairly confident in the queries, but I don't know what else could be the issue.

Edit 1 - Fixed the mistake in the insert/delete query pointed out by @Stefan - brox IT-Solutions. At first this didn't seem to work. I was still able to query the data that should have been removed/changed by using the GraphDB browser GUI. I think the query result was being cached and that the cache result lasts X minutes post query. So waiting ~10 minutes (while writing a response) was enough time for the cache to expire and the actual query results to display. I'll have to keep these things in mind: 1) be more careful with copy/pasting between queries, and 2) don't spam queries through the GraphDB browser GUI.

1
  • 2
    That Update query can’t work, because ?gid has no bindings. In the WHERE clause, you are binding ?sid, not ?gid. Commented Jul 19, 2024 at 7:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.