You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Lorenz Bühmann (Jira)" <ji...@apache.org> on 2022/02/25 09:05:00 UTC

[jira] [Created] (JENA-2292) WKT literal inequality check fails

Lorenz Bühmann created JENA-2292:
------------------------------------

             Summary: WKT literal inequality check fails 
                 Key: JENA-2292
                 URL: https://issues.apache.org/jira/browse/JENA-2292
             Project: Apache Jena
          Issue Type: Bug
          Components: GeoSPARQL
    Affects Versions: Jena 4.4.0
            Reporter: Lorenz Bühmann


The inequality check of WKT literals fails in filter expression:
{code:sql}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
SELECT * {
  VALUES ?wkt1 {"Point(11.416666666667 53.633333333333)"^^geo:wktLiteral "Point(11.575 48.1375)"^^geo:wktLiteral}
  VALUES ?wkt2 {"Point(11.416666666667 53.633333333333)"^^geo:wktLiteral "Point(11.575 48.1375)"^^geo:wktLiteral}
  FILTER(?wkt1 != ?wkt2)
} 
{code}
Equality check on the other hand works:
{code:sql}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
SELECT * {
  VALUES ?wkt1 {"Point(11.416666666667 53.633333333333)"^^geo:wktLiteral "Point(11.575 48.1375)"^^geo:wktLiteral}
  VALUES ?wkt2 {"Point(11.416666666667 53.633333333333)"^^geo:wktLiteral "Point(11.575 48.1375)"^^geo:wktLiteral}
  FILTER(?wkt1 = ?wkt2)
} 
{code}
I don't know if this is intended by SPARQL itself for non-standard datatypes, while checking code it goes into
{code:java}
case VSPACE_UNKNOWN:
{
    // One or two unknown value spaces, or one has a lang tag (but not both).
    Node node1 = nv1.asNode() ;
    Node node2 = nv2.asNode() ;

    if ( ! SystemARQ.ValueExtensions )
        // No value extensions => raw rdfTermEquals
        return NodeFunctions.rdfTermEquals(node1, node2) ;

    // Some "value spaces" are know to be not equal (no overlap).
    // Like one literal with a language tag, and one without can't be sameAs.

    if ( ! node1.isLiteral() || ! node2.isLiteral() )
        // Can't both be non-literals - that's VSPACE_NODE
        // One or other not a literal => not sameAs
        return false ;

    // Two literals at this point.

    if ( NodeFunctions.sameTerm(node1, node2) )
        return true ;

    if ( ! node1.getLiteralLanguage().equals("") ||
         ! node2.getLiteralLanguage().equals("") )
        // One had lang tag but weren't sameNode => not equals
        return false ;

    raise(new ExprEvalException("Unknown equality test: "+nv1+" and "+nv2)) ;
    throw new ARQInternalErrorException("raise returned (sameValueAs)") ;
} {code}
and here indeed {{NodeFunctions.sameTerm(node1, node2)}} returns false but this isn't forwarded as return value but instead an exception is thrown, thus, inequality check in a filter always leads to error and thus false.
It also will fail for equality check of non equal WKT literals of course, all cases here:


{code:sql}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>

SELECT * {
  BIND("Point(11.416666666667 53.633333333333)"^^geo:wktLiteral = "Point(11.416666666667 53.633333333333)"^^geo:wktLiteral AS ?equal_true)
  BIND("Point(11.416666666667 53.633333333333)"^^geo:wktLiteral = "Point(11.575 48.1375)"^^geo:wktLiteral AS ?equal_false)
  
  BIND("Point(11.416666666667 53.633333333333)"^^geo:wktLiteral != "Point(11.575 48.1375)"^^geo:wktLiteral AS ?not_equal_true)
  BIND("Point(11.416666666667 53.633333333333)"^^geo:wktLiteral != "Point(11.416666666667 53.633333333333)"^^geo:wktLiteral AS ?not_equal_false)
} 
{code}

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)