Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILTER on langString literals does not work with N3 as source #1146

Closed
gvanderh opened this issue Jan 31, 2023 · 12 comments
Closed

FILTER on langString literals does not work with N3 as source #1146

gvanderh opened this issue Jan 31, 2023 · 12 comments

Comments

@gvanderh
Copy link

gvanderh commented Jan 31, 2023

// add a quad with a language string
const store = new N3.Store();
store.addQuad(namedNode('http://ex.com/s'), namedNode('http://ex.com/p'), literal('abc', 'en'));

// query it using SPARQL with a FILTER
const eng = new comunica.QueryEngine();
const bindings = await eng.queryBindings('SELECT ?o WHERE { ?s ?p ?o. FILTER(?o = "abc"@en) }', { sources: [ store ] });

Any FILTER on ?o in the example fails (with or without language string, = or !=). That is, as soon as a FILTER on the langString literal is present in the query, it won't return any results anymore. No crash or log warnings, just an empty result set.

Observed on Comunica v2.6.0 in combination with N3 v1.16.3.


Bounty

A bounty has been placed on this issue by:

Comunica Association
€272

Click here to learn more if you're interested in claiming this bounty by resolving this issue.

@rubensworks rubensworks added this to To Do (prio:medium) in Maintenance via automation Jan 31, 2023
@github-actions
Copy link

Thanks for reporting!

@rubensworks
Copy link
Member

This is surprising, I thought we had spec tests for this.

@rubensworks
Copy link
Member

A bounty has been placed on this issue via the Comunica Association (see original post).

@danielbeeke
Copy link
Contributor

I have reproduced with the code in the description.

The logger shows:

[2023-02-21T11:17:47.764Z]  WARN: Error occurred while filtering. { error: { [Error: Equality test for literals with unsupported datatypes] args: [ LangStringLiteral { expressionType: 'term', typedValue: 'abc', dataType: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString', strValue: 'abc', language: 'en', termType: 'literal' }, LangStringLiteral { expressionType: 'term', typedValue: 'abc', dataType: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString', strValue: 'abc', language: 'en', termType: 'literal' } ] }, bindings: '{\n  "s": "http://ex.com/s",\n  "p": "http://ex.com/p",\n  "o": "\\"abc\\"@en"\n}', actor: 'urn:comunica:default:query-operation/actors#filter' }

That pointed me towards:

https://github.com/comunica/sparqlee/blob/master/lib/functions/RegularFunctions.ts#L111

That looks kind of odd to me.
When I remove the throw Error, it works. But there probably is a reason why Sparqlee does not want to check literals.

@danielbeeke
Copy link
Contributor

Could this be related?

comunica/sparqlee#2

@rubensworks
Copy link
Member

@jitsedesmet Do you have any thoughts on the findings of @danielbeeke?

@danielbeeke
Copy link
Contributor

I think it should be possible to check against Literals
See: https://www.w3.org/TR/rdf-concepts/#section-Literal-Equality

Also the equality check also happens in the Term itself.

@jitsedesmet
Copy link
Member

I think this is an error in the code.
Like you said, this line throws the error: https://github.com/comunica/sparqlee/blob/master/lib/functions/RegularFunctions.ts#L111
And the error it throws is: https://github.com/comunica/sparqlee/blob/master/lib/util/Errors.ts#L69
It looks like the provided link there: https://www.w3.org/TR/sparql11-query/#func-RDFterm-equal
doesn't seem to be implemented correctly? The error should only be thrown if the literals are not the same.

Returns TRUE if term1 and term2 are the same RDF term as defined in Resource Description Framework (RDF): Concepts and Abstract Syntax [CONCEPTS]; produces a type error if the arguments are both literal but are not the same RDF term *; returns FALSE otherwise.

@danielbeeke
Copy link
Contributor

Great, same findings as me, I created PR to fix it.

@jeswr
Copy link
Member

jeswr commented Mar 23, 2023

Not sure this is fully resolved - see #1182 (reply in thread).

@jeswr jeswr reopened this Mar 23, 2023
Maintenance automation moved this from Done to To Do (prio:medium) Mar 23, 2023
@rubensworks
Copy link
Member

Might be better to create a separate issue for this. This issue is about the equality operator, while the new one seems to be about IN.

@jeswr
Copy link
Member

jeswr commented Mar 23, 2023

Closing in favour of #1185

@jeswr jeswr closed this as completed Mar 23, 2023
Maintenance automation moved this from To Do (prio:medium) to Done Mar 23, 2023
jitsedesmet pushed a commit to jitsedesmet/comunica that referenced this issue Aug 8, 2023
jitsedesmet pushed a commit to jitsedesmet/comunica that referenced this issue Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Maintenance
  
Done
Development

No branches or pull requests

5 participants