Skip to content

feat: add getDataframeWithMetadata for RDFReader#63

Open
AuPath wants to merge 1 commit into
mainfrom
feat-62-rdfreader-sparql-metadata
Open

feat: add getDataframeWithMetadata for RDFReader#63
AuPath wants to merge 1 commit into
mainfrom
feat-62-rdfreader-sparql-metadata

Conversation

@AuPath

@AuPath AuPath commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #62. Add support for returning SPARQL SELECT binding metadata according to the SPARQL JSON Results format. Each binding now includes its value, RDF term type (URI, blank node, or literal), datatype (e.g., xsd:string), and language tag when applicable.

This functionality is exposed through a new method rather than getDataframe(), preserving backward compatibility while making the feature opt-in.

An example usage in an MTL mapping can be seen here:

#set ( $rows = $reader.getDataframeWithMetadata("SELECT ?s ?name ?label WHERE { ?s a gtfs:Agency ; foaf:name ?name ; rdfs:label ?label . }") )
@prefix ex: <http://example.com/> .
#foreach($row in $rows)<$row.s.value> ex:name "$row.name.value" ; ex:nameType "$row.name.type" ; ex:nameDatatype "$row.name.datatype" ; ex:label "$row.label.value" ; ex:labelLang "$row.label.lang" .
#end

The map containing the value and metadata is accessed by using the binding specified in the sparql query. Then the 'value', 'type' and other metadata can be accessed using dot notation via standard keys which are fixed ('value', 'type', ...).

Closes #62. Add support for returning SPARQL SELECT binding metadata
according to the SPARQL JSON Results format. Each binding now includes
its value, RDF term type (URI, blank node, or literal), datatype (e.g.,
xsd:string), and language tag when applicable.

This functionality is exposed through a new method rather than
getDataframe(), preserving backward compatibility while making the
feature opt-in.
@AuPath AuPath requested a review from marioscrock June 29, 2026 09:06
@AuPath AuPath self-assigned this Jun 29, 2026

<http://sprint-transport.eu/data/agencies/BEST-AGENCY>
ex:name "Best Agency" ;
ex:nameType "literal" ;

@marioscrock marioscrock Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be encoded with some sort of "standardised value"? I would propose using the canonical IRIs already as values in the returned dataframe

rdf:IRI
rdf:BlankNode
rdfs:Literal

(note: Literal is under rdfs, the other two under rdf namespace)

ex:nameType "literal" ;
ex:nameDatatype "http://www.w3.org/2001/XMLSchema#string" ;
ex:label "Migliore" ;
ex:labelLang "it" .

@marioscrock marioscrock Jul 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use xsd:language data type for labelLang— http://www.w3.org/2001/XMLSchema#language

ex:labelLang "it"^^xsd:language

I know it's just a test, but we want to provide good example 😄

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accessing RDF term type metadata in SPARQL SELECT in mapping

2 participants