SmartDataAnalytics / RdfProcessingToolkit

Command line interface based RDF processing toolkit to run sequences of SPARQL statements ad-hoc on RDF datasets, streams of bindings and streams of named graphs with support for processing JSON, CSV and XML using function extensions
https://smartdataanalytics.github.io/RdfProcessingToolkit/
Other
40 stars 3 forks source link

Debug queries #4

Closed GordianDziwis closed 5 years ago

GordianDziwis commented 6 years ago

Something like echo for debugging queries would be nice.

Aklakan commented 6 years ago

Update on the issue: This is about a function extension such as

SELECT * {
  ...
  BIND(...complex expression(?a, ?b, ?c) ... AS ?x)
  FILTER(fn:stderr(CONCAT("Obtained ", ?x, " from input ", ?a, ?b, ?c))
}  

So we should create a filter function that always yields true but as a side effect prints out its argument.

Note: Select queries can already be used for debug output: Their output goes to STDERR - whereas CONSTRUCT queries go to STDOUT - so only the latter produces data output.

Aklakan commented 5 years ago

It turns out that Jena already has an (undocumented according to [1]) afn:print function. It may be useful to create a new issue in order to have a similar function that logs via slf4j; but as this issue was about having the feature at all it can be closed.

[1] https://jena.apache.org/documentation/query/library-function.html

Code from Jena 3.11:

package org.apache.jena.sparql.function.library;

/** Function that prints it's argument to stdout (debugging aid) */
public class print extends FunctionBase1 {