Skip to content

sparql-anything: an all-filtered chunk is reported as an unreadable input #820

Description

@ddeboer

SparqlAnythingConverter.convert() rejects any process whose --output is empty, on the reasoning that SPARQL Anything exits 0 when it cannot read or parse an input. That reasoning is right, but the check cannot tell that case from a chunk whose rows were all filtered out by the query, which is legitimate and also yields a 0-byte file.

Reproduction

A chunk of three alternateNamesV2 rows whose isolanguage is link, post and fr_1793, run through geonames-rdf’s config/alternate-names.rq, which filters all three out. The pinned jar (1.2.0-RC1) writes a 0-byte --output and exits 0. convert() then throws:

SPARQL Anything produced no output for ‘config/alternate-names.rq’ over ‘…’; it exits successfully when it cannot read or parse an input

and stops the chunks still running. map.sh in geonames-rdf accepts such a chunk. With the default 1M rows a remainder chunk this selective is unlikely, but a small chunk size for a smoke test hits it, and the message then sends the reader after the wrong cause.

Suggested fix

Distinguish “no triples” from “unreadable input”. Options, roughly in order of preference:

  • Only treat an empty output as a failure when the chunk itself could not have produced one: check that the chunk (or load) file exists and is non-empty before starting the process, and accept an empty output otherwise. That keeps the guard for the case it was written for – a missing or unparsable file – and lets an all-filtered chunk through.
  • Read SPARQL Anything’s output for the log line it writes when it cannot read an input, and fail on that rather than on the size of the result.
  • Least good: an opt-out per job.

Found while porting geonames-rdf (netwerk-digitaal-erfgoed/geonames-rdf#50), see #782.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions