SPARQL-star Evaluation Tests

Generated from:manifest.jsonld
creator: RDF-star Interest Group within the W3C RDF-DEV Community Group
issued:2021-06-21
modified:2021-07-18
see also:https://w3c.github.io/rdf-star/tests/sparql/eval/README

Entries:

About this test suite

https://w3c.github.io/rdf-star/tests/sparql/eval/README

SPARQL-star - all graph triples (JSON results) 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-results-1.rq
PREFIX :       <http://example/>

SELECT * {
    ?s ?p ?o
}
Data: data-0.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
:a :q <<:a :b :c>> .

:f :g << <<:x1 :y1 123 >> :p :o >> .

:f :g << :s :p <<:x2 :y3 123 >> >> .

<< :s1 :p1 :o1 >> :q << :s1 :p1 :o1 >> .

:a :b :c {| :q1 :z1 |} .


MUST result into
sparql-star-results-1.srj
{ "head": {
    "vars": [ "s" , "p" , "o" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "uri" , "value": "http://example/c" }
          }
        } ,
        "p": { "type": "uri" , "value": "http://example/q1" } ,
        "o": { "type": "uri" , "value": "http://example/z1" }
      } ,
      { 
        "s": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "uri" , "value": "http://example/c" }
          }
        } ,
        "p": { "type": "uri" , "value": "http://example/q" } ,
        "o": { "type": "uri" , "value": "http://example/z" }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/a" } ,
        "p": { "type": "uri" , "value": "http://example/b" } ,
        "o": { "type": "uri" , "value": "http://example/c" }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/a" } ,
        "p": { "type": "uri" , "value": "http://example/q" } ,
        "o": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "uri" , "value": "http://example/c" }
          }
        }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/f" } ,
        "p": { "type": "uri" , "value": "http://example/g" } ,
        "o": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/s" } ,
            "predicate": { "type": "uri" , "value": "http://example/p" } ,
            "object":   {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/x2" } ,
                "predicate": { "type": "uri" , "value": "http://example/y3" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
              }
            }
          }
        }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/f" } ,
        "p": { "type": "uri" , "value": "http://example/g" } ,
        "o": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/x1" } ,
                "predicate": { "type": "uri" , "value": "http://example/y1" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example/p" } ,
            "object":   { "type": "uri" , "value": "http://example/o" }
          }
        }
      } ,
      { 
        "s": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/s1" } ,
            "predicate": { "type": "uri" , "value": "http://example/p1" } ,
            "object":   { "type": "uri" , "value": "http://example/o1" }
          }
        } ,
        "p": { "type": "uri" , "value": "http://example/q" } ,
        "o": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/s1" } ,
            "predicate": { "type": "uri" , "value": "http://example/p1" } ,
            "object":   { "type": "uri" , "value": "http://example/o1" }
          }
        }
      }
    ]
  }
}

SPARQL-star - all graph triples (XML results) 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-results-1.rq
PREFIX :       <http://example/>

SELECT * {
    ?s ?p ?o
}
Data: data-0.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
:a :q <<:a :b :c>> .

:f :g << <<:x1 :y1 123 >> :p :o >> .

:f :g << :s :p <<:x2 :y3 123 >> >> .

<< :s1 :p1 :o1 >> :q << :s1 :p1 :o1 >> .

:a :b :c {| :q1 :z1 |} .


MUST result into
sparql-star-results-1.srx
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
  <head>
    <variable name="s"/>
    <variable name="p"/>
    <variable name="o"/>
  </head>
  <results>
    <result>
      <binding name="s">
        <triple>
          <subject>
            <uri>http://example/a</uri>
          </subject>
          <predicate>
            <uri>http://example/b</uri>
          </predicate>
          <object>
            <uri>http://example/c</uri>
          </object>
        </triple>
      </binding>
      <binding name="p">
        <uri>http://example/q1</uri>
      </binding>
      <binding name="o">
        <uri>http://example/z1</uri>
      </binding>
    </result>
    <result>
      <binding name="s">
        <triple>
          <subject>
            <uri>http://example/a</uri>
          </subject>
          <predicate>
            <uri>http://example/b</uri>
          </predicate>
          <object>
            <uri>http://example/c</uri>
          </object>
        </triple>
      </binding>
      <binding name="p">
        <uri>http://example/q</uri>
      </binding>
      <binding name="o">
        <uri>http://example/z</uri>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://example/a</uri>
      </binding>
      <binding name="p">
        <uri>http://example/b</uri>
      </binding>
      <binding name="o">
        <uri>http://example/c</uri>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://example/a</uri>
      </binding>
      <binding name="p">
        <uri>http://example/q</uri>
      </binding>
      <binding name="o">
        <triple>
          <subject>
            <uri>http://example/a</uri>
          </subject>
          <predicate>
            <uri>http://example/b</uri>
          </predicate>
          <object>
            <uri>http://example/c</uri>
          </object>
        </triple>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://example/f</uri>
      </binding>
      <binding name="p">
        <uri>http://example/g</uri>
      </binding>
      <binding name="o">
        <triple>
          <subject>
            <uri>http://example/s</uri>
          </subject>
          <predicate>
            <uri>http://example/p</uri>
          </predicate>
          <object>
            <triple>
              <subject>
                <uri>http://example/x2</uri>
              </subject>
              <predicate>
                <uri>http://example/y3</uri>
              </predicate>
              <object>
                <literal datatype="http://www.w3.org/2001/XMLSchema#integer">123</literal>
              </object>
            </triple>
          </object>
        </triple>
      </binding>
    </result>
    <result>
      <binding name="s">
        <uri>http://example/f</uri>
      </binding>
      <binding name="p">
        <uri>http://example/g</uri>
      </binding>
      <binding name="o">
        <triple>
          <subject>
            <triple>
              <subject>
                <uri>http://example/x1</uri>
              </subject>
              <predicate>
                <uri>http://example/y1</uri>
              </predicate>
              <object>
                <literal datatype="http://www.w3.org/2001/XMLSchema#integer">123</literal>
              </object>
            </triple>
          </subject>
          <predicate>
            <uri>http://example/p</uri>
          </predicate>
          <object>
            <uri>http://example/o</uri>
          </object>
        </triple>
      </binding>
    </result>
    <result>
      <binding name="s">
        <triple>
          <subject>
            <uri>http://example/s1</uri>
          </subject>
          <predicate>
            <uri>http://example/p1</uri>
          </predicate>
          <object>
            <uri>http://example/o1</uri>
          </object>
        </triple>
      </binding>
      <binding name="p">
        <uri>http://example/q</uri>
      </binding>
      <binding name="o">
        <triple>
          <subject>
            <uri>http://example/s1</uri>
          </subject>
          <predicate>
            <uri>http://example/p1</uri>
          </predicate>
          <object>
            <uri>http://example/o1</uri>
          </object>
        </triple>
      </binding>
    </result>
  </results>
</sparql>

SPARQL-star - match constant quoted triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-basic-2.rq
PREFIX :       <http://example/>

SELECT * {
    <<:a :b :c>> ?p ?o
}
Data: data-1.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
MUST result into
sparql-star-basic-2.srj
{ "head": {
    "vars": [ "p" , "o" ]
  } ,
  "results": {
    "bindings": [
      { 
        "p": { "type": "uri" , "value": "http://example/q" } ,
        "o": { "type": "uri" , "value": "http://example/z" }
      }
    ]
  }
}

SPARQL-star - match quoted triple, var subject 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-basic-3.rq
PREFIX :       <http://example/>

SELECT * {
    <<?s :b :c>> ?p ?o
}
Data: data-1.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
MUST result into
sparql-star-basic-3.srj
{ "head": {
    "vars": [ "s" , "p" , "o" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/a" } ,
        "p": { "type": "uri" , "value": "http://example/q" } ,
        "o": { "type": "uri" , "value": "http://example/z" }
      }
    ]
  }
}

SPARQL-star - match quoted triple, var predicate 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-basic-4.rq
PREFIX :       <http://example/>

SELECT * {
    <<:a ?p :c>> ?q :z .
}
Data: data-1.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
MUST result into
sparql-star-basic-4.srj
{ "head": {
    "vars": [ "p" , "q" ]
  } ,
  "results": {
    "bindings": [
      { 
        "p": { "type": "uri" , "value": "http://example/b" } ,
        "q": { "type": "uri" , "value": "http://example/q" }
      }
    ]
  }
}

SPARQL-star - match quoted triple, var object 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-basic-5.rq
PREFIX :       <http://example/>

SELECT * {
    <<:a :b ?o>> ?q :z .
}
Data: data-1.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
MUST result into
sparql-star-basic-5.srj
{ "head": {
    "vars": [ "o" , "q" ]
  } ,
  "results": {
    "bindings": [
      { 
        "o": { "type": "uri" , "value": "http://example/c" } ,
        "q": { "type": "uri" , "value": "http://example/q" }
      }
    ]
  }
}

SPARQL-star - no match of quoted triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-basic-6.rq
PREFIX :       <http://example/>

SELECT * {
    <<?a ?b :nomatch >> ?q :z .
}
Data: data-1.ttl
PREFIX : <http://example/>

<<:a :b :c>> :q :z .
MUST result into
sparql-star-basic-6.srj
{ "head": {
    "vars": [ "a" , "b" , "q" ]
  } ,
  "results": {
    "bindings": [
      
    ]
  }
}

SPARQL-star - Asserted and quoted triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-01.rq
PREFIX :       <http://example/>

SELECT * {
 :s :p1 ?o .
 <<:s :p1 ?o>> ?q ?z .
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-01.srj
{ "head": {
    "vars": [ "o" , "q" , "z" ]
  } ,
  "results": {
    "bindings": [
      { 
        "o": { "type": "uri" , "value": "http://example/o" } ,
        "q": { "type": "uri" , "value": "http://example/b" } ,
        "z": { "type": "uri" , "value": "http://example/a2" }
      } ,
      { 
        "o": { "type": "uri" , "value": "http://example/o" } ,
        "q": { "type": "uri" , "value": "http://example/q" } ,
        "z": { "type": "uri" , "value": "http://example/z" }
      }
    ]
  }
}

SPARQL-star - Asserted and quoted triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-02.rq
PREFIX :       <http://example/>

SELECT * {
  <<:s :p1 ?o>> ?q ?z .
  :s :p1 ?o .
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-02.srj
{ "head": {
    "vars": [ "o" , "q" , "z" ]
  } ,
  "results": {
    "bindings": [
      { 
        "o": { "type": "uri" , "value": "http://example/o" } ,
        "q": { "type": "uri" , "value": "http://example/b" } ,
        "z": { "type": "uri" , "value": "http://example/a2" }
      } ,
      { 
        "o": { "type": "uri" , "value": "http://example/o" } ,
        "q": { "type": "uri" , "value": "http://example/q" } ,
        "z": { "type": "uri" , "value": "http://example/z" }
      }
    ]
  }
}

SPARQL-star - Pattern - Variable for quoted triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-03.rq
PREFIX :       <http://example/>

## Connected via triple term
SELECT * {
 ?s :b ?o .
 ?o :b ?z .
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-03.srj
{ "head": {
    "vars": [ "s" , "o" , "z" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/a1" } ,
        "o": {
          "type": "triple" , 
          "value": {
            "subject":   { "type": "uri" , "value": "http://example/s" } ,
            "predicate": { "type": "uri" , "value": "http://example/p1" } ,
            "object":    { "type": "uri" , "value": "http://example/o" }
          }
        } ,
        "z": { "type": "uri" , "value": "http://example/a2" }
      }
    ]
  }
}

SPARQL-star - Pattern - No match 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-04.rq
PREFIX :       <http://example/>

## No match
SELECT * {
   ?s ?p << :s :p1 :zz >> .
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-04.srj
{ "head": {
    "vars": [ "s" , "p" ]
  } ,
  "results": {
    "bindings": [
      
    ]
  }
}

SPARQL-star - Pattern - match variables in triple terms 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-05.rq
PREFIX :       <http://example/>

# Matching Variables
SELECT * {
   <<?s ?p ?o>> ?Q <<?s ?p ?o>>
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-05.srj
{ "head": {
    "vars": [ "s" , "p" , "o" , "Q" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/s" } ,
        "p": { "type": "uri" , "value": "http://example/p2" } ,
        "o": { "type": "uri" , "value": "http://example/o" } ,
        "Q": { "type": "uri" , "value": "http://example/sym" }
      }
    ]
  }
}

SPARQL-star - Pattern - Nesting 1 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-06.rq
PREFIX :       <http://example/>

# Nesting
SELECT * {
  << <<:s :p2 :o>> :p3 :z>> :q  ?q .
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-06.srj
{ "head": {
    "vars": [ "q" ]
  } ,
  "results": {
    "bindings": [
      { 
        "q": { "type": "uri" , "value": "http://example/o" }
      }
    ]
  }
}

SPARQL-star - Pattern - Nesting - 2 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-07.rq
PREFIX :       <http://example/>

# Nesting
SELECT * {
  << <<?s :p2 :o>> :p3 ?x>> :q ?q 
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-07.srj
{ "head": {
    "vars": [ "s" , "x" , "q" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/s" } ,
        "x": { "type": "uri" , "value": "http://example/z" } ,
        "q": { "type": "uri" , "value": "http://example/o" }
      }
    ]
  }
}

SPARQL-star - Pattern - Match and nesting 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-08.rq
PREFIX :       <http://example/>

# Nesting via match
SELECT * {
  ?t :p3 :z .
  << ?t  :p3 :z >> :q :o . 
}
Data: data-2.ttl
PREFIX :       <http://example/>

:s :p1 :o .
<<:s :p1 :o>> :q :z .

# pattern-3
:a1 :b <<:s :p1 :o>>  .
<<:s :p1 :o>> :b :a2 .

# pattern-5
:s :p2 :o .
<<:s :p2 :o>> :sym <<:s :p2 :o>> .

# pattern-6
<<:s :p2 :o>> :p3 :z .
<< <<:s :p2 :o>> :p3 :z >> :q :o .
MUST result into
sparql-star-pattern-08.srj
{ "head": {
    "vars": [ "t" ]
  } ,
  "results": {
    "bindings": [
      { 
        "t": {
          "type": "triple" , 
          "value": {
            "subject":   { "type": "uri" , "value": "http://example/s" } ,
            "predicate": { "type": "uri" , "value": "http://example/p2" } ,
            "object":    { "type": "uri" , "value": "http://example/o" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Pattern - Same variable 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-pattern-09.rq
PREFIX :       <http://example/>

SELECT * {
    { <<?s ?p :o>> ?p ?z }
    UNION
    { ?z ?p  <<?s ?p :o>> }
}
Data: data-5.ttl
PREFIX :       <http://example/>

<<:s1 :p :o>> :q :z .
<<:s2 :p :o>> :p "same-p" .
<<:s3 :p :o>> : "same-p" .


:z1 :q << :s1 :p :o >> .
:z2 :p << :s2 :p :o >> .

MUST result into
sparql-star-pattern-09.srj
{ "head": {
    "vars": [ "s" , "p" , "z" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "uri" , "value": "http://example/s2" } ,
        "p": { "type": "uri" , "value": "http://example/p" } ,
        "z": { "type": "literal" , "value": "same-p" }
      } ,
      { 
        "s": { "type": "uri" , "value": "http://example/s2" } ,
        "p": { "type": "uri" , "value": "http://example/p" } ,
        "z": { "type": "uri" , "value": "http://example/z2" }
      }
    ]
  }
}

SPARQL-star - CONSTRUCT with constant template 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-construct-1.rq
PREFIX :       <http://example/>

CONSTRUCT {
  <<:a :b :c >> :q :z .
} WHERE { }
Data: data-3.ttl
PREFIX : <http://example/>

:a :b :c {| :q :z |} .
:s :p :o .
MUST result into
sparql-star-construct-1.ttl
PREFIX :      <http://example/>

<< :a :b :c >>  :q  :z .

SPARQL-star - CONSTRUCT WHERE with constant template 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-construct-2.rq
PREFIX :       <http://example/>

CONSTRUCT WHERE {
  <<:a :b :c >> :q :z .
}
Data: data-3.ttl
PREFIX : <http://example/>

:a :b :c {| :q :z |} .
:s :p :o .
MUST result into
sparql-star-construct-2.ttl
PREFIX :      <http://example/>

<< :a :b :c >>  :q  :z .

SPARQL-star - CONSTRUCT - about every triple 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-construct-3.rq
PREFIX :       <http://example/>

CONSTRUCT {
   << ?s ?p ?o >> :source :ABC .
} WHERE {
   ?s ?p ?o .
}
Data: data-3.ttl
PREFIX : <http://example/>

:a :b :c {| :q :z |} .
:s :p :o .
MUST result into
sparql-star-construct-3.ttl
PREFIX :      <http://example/>

<< << :a :b :c >> :q :z >>
        :source  :ABC .

<< :a :b :c >>  :source  :ABC .

<< :s :p :o >>  :source  :ABC .

SPARQL-star - CONSTRUCT with annotation syntax 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-construct-4.rq
PREFIX :       <http://example/>

CONSTRUCT {
   :a :b ?c {| :source :ABC |} .
} WHERE {
   :a :b ?c .
}
Data: data-3.ttl
PREFIX : <http://example/>

:a :b :c {| :q :z |} .
:s :p :o .
MUST result into
sparql-star-construct-4.ttl
PREFIX :      <http://example/>

:a      :b      :c .

<< :a :b :c >>  :source  :ABC .

SPARQL-star - CONSTRUCT WHERE with annotation syntax 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-construct-5.rq
PREFIX :       <http://example/>

CONSTRUCT WHERE {
   :a :b ?c {| ?q ?z |} .
}
Data: data-3.ttl
PREFIX : <http://example/>

:a :b :c {| :q :z |} .
:s :p :o .
MUST result into
sparql-star-construct-5.ttl
PREFIX :      <http://example/>

:a      :b      :c .

<< :a :b :c >>  :q  :z .

SPARQL-star - GRAPH 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-graphs-1.rq
PREFIX :       <http://example/>

SELECT * {
   :s :p ?o .
   GRAPH ?g { <<:s :p ?o>> ?q ?z }
}
Data: data-4.trig
PREFIX : <http://example/>

:s :p :o1 .

GRAPH :g {
     <<:s :p :o1 >> :q1 :z1 .
     <<:s :p :o2 >> :q2 :z2 .
}

GRAPH :g1 { _:b :r :o3 . _:b :r :o4 . }

GRAPH :g2 { << _:b :r :o3 >> :pb "abc" . }

MUST result into
sparql-star-graphs-1.srj
{ "head": {
    "vars": [ "o" , "q" , "z" , "g" ]
  } ,
  "results": {
    "bindings": [
      { 
        "o": { "type": "uri" , "value": "http://example/o1" } ,
        "q": { "type": "uri" , "value": "http://example/q1" } ,
        "z": { "type": "uri" , "value": "http://example/z1" } ,
        "g": { "type": "uri" , "value": "http://example/g" }
      }
    ]
  }
}

SPARQL-star - GRAPHs with blank node 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-graphs-2.rq
PREFIX :       <http://example/>

SELECT * {
   GRAPH ?g1 { ?s ?p ?o }
   GRAPH ?g2 { << ?s ?p ?o >> ?q ?z }
}
Data: data-4.trig
PREFIX : <http://example/>

:s :p :o1 .

GRAPH :g {
     <<:s :p :o1 >> :q1 :z1 .
     <<:s :p :o2 >> :q2 :z2 .
}

GRAPH :g1 { _:b :r :o3 . _:b :r :o4 . }

GRAPH :g2 { << _:b :r :o3 >> :pb "abc" . }

MUST result into
sparql-star-graphs-2.srj
{ "head": {
    "vars": [ "s" , "p" , "o" , "g1" , "q" , "z" , "g2" ]
  } ,
  "results": {
    "bindings": [
      { 
        "s": { "type": "bnode" , "value": "b0" } ,
        "p": { "type": "uri" , "value": "http://example/r" } ,
        "o": { "type": "uri" , "value": "http://example/o3" } ,
        "g1": { "type": "uri" , "value": "http://example/g1" } ,
        "q": { "type": "uri" , "value": "http://example/pb" } ,
        "z": { "type": "literal" , "value": "abc" } ,
        "g2": { "type": "uri" , "value": "http://example/g2" }
      }
    ]
  }
}

SPARQL-star - Embedded triple - BIND - CONSTRUCT 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-expr-01.rq
PREFIX : <http://example/>

CONSTRUCT {
  ?t :graph ?g .
} WHERE {
  GRAPH ?g {
    ?s ?p ?o .
    BIND(<<?s ?p  ?o>> AS ?t)
  }
}
Data: data-4.trig
PREFIX : <http://example/>

:s :p :o1 .

GRAPH :g {
     <<:s :p :o1 >> :q1 :z1 .
     <<:s :p :o2 >> :q2 :z2 .
}

GRAPH :g1 { _:b :r :o3 . _:b :r :o4 . }

GRAPH :g2 { << _:b :r :o3 >> :pb "abc" . }

MUST result into
sparql-star-expr-01.ttl
PREFIX :      <http://example/>

<< << :s :p :o2 >> :q2 :z2 >>
        :graph  :g .

<< _:b0 :r :o4 >>  :graph  :g1 .

<< _:b0 :r :o3 >>  :graph  :g1 .

<< << :s :p :o1 >> :q1 :z1 >>
        :graph  :g .

<< << _:b0 :r :o3 >> :pb "abc" >>
        :graph  :g2 .

SPARQL-star - Embedded triple - Functions 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-expr-02.rq
PREFIX :       <http://example/>

SELECT * {
  VALUES ?t {
         <<:s :p :o >>
         :x
          <<:s :p :o1 >>
          }
  FILTER(isTriple(?t))
  FILTER(SUBJECT(?t) = :s)
  FILTER(PREDICATE(?t) = :p)
  FILTER(OBJECT(?t) = :o)
}
Data: empty.nq

MUST result into
sparql-star-expr-02.srj
{ "head": {
    "vars": [ "t" ]
  } ,
  "results": {
    "bindings": [
      { 
        "t": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/s" } ,
            "predicate": { "type": "uri" , "value": "http://example/p" } ,
            "object":   { "type": "uri" , "value": "http://example/o" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Embedded triple - sameTerm 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-op-1.rq
PREFIX :       <http://example/>

SELECT * {
  ?x :left ?left .
  ?x :right ?right .
  FILTER( sameTerm(?left, ?right) )
}
Data: data-7.ttl
PREFIX : <http://example/>

:x1 :left  << :a :b 123 >> .
:x1 :right << :a :b 123.0 >> .

:x2 :left  << :a :b 123 >> .
:x2 :right << :a :b 123 >> .

:x3 :left  << << :a :b 123 >> :q 999 >> .
:x3 :right << << :a :b 123.0 >> :q 999 >> .

:x4 :left  << :a :b 123 >> .
:x4 :right << :c :d 123 >> .

:x5 :left  << _:bnode1 :b 123 >> .
:x5 :right << _:bnode1 :b 123 >> .

:x6 :left  << _:bnode2 :b 123e0 >> .
:x6 :right << _:bnode2 :b 123 >> .

:x7 :left  << :a :b 9 >> .
:x7 :right << :a :b 123 >> .


MUST result into
sparql-star-op-1.srj
{ "head": {
    "vars": [ "x" , "left" , "right" ]
  } ,
  "results": {
    "bindings": [
      { 
        "x": { "type": "uri" , "value": "http://example/x2" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x5" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Embedded triple - value-equality 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-op-2.rq
PREFIX :       <http://example/>

SELECT * {
  ?x :left ?left .
  ?x :right ?right .
  FILTER( ! sameTerm(?left, ?right) )
  FILTER(?left = ?right)
}
Data: data-7.ttl
PREFIX : <http://example/>

:x1 :left  << :a :b 123 >> .
:x1 :right << :a :b 123.0 >> .

:x2 :left  << :a :b 123 >> .
:x2 :right << :a :b 123 >> .

:x3 :left  << << :a :b 123 >> :q 999 >> .
:x3 :right << << :a :b 123.0 >> :q 999 >> .

:x4 :left  << :a :b 123 >> .
:x4 :right << :c :d 123 >> .

:x5 :left  << _:bnode1 :b 123 >> .
:x5 :right << _:bnode1 :b 123 >> .

:x6 :left  << _:bnode2 :b 123e0 >> .
:x6 :right << _:bnode2 :b 123 >> .

:x7 :left  << :a :b 9 >> .
:x7 :right << :a :b 123 >> .


MUST result into
sparql-star-op-2.srj
{ "head": {
    "vars": [ "x" , "left" , "right" ]
  } ,
  "results": {
    "bindings": [
      { 
        "x": { "type": "uri" , "value": "http://example/x6" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#double" , "value": "123e0" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x1" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#decimal" , "value": "123.0" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x3" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/a" } ,
                "predicate": { "type": "uri" , "value": "http://example/b" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example/q" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/a" } ,
                "predicate": { "type": "uri" , "value": "http://example/b" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#decimal" , "value": "123.0" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example/q" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Embedded triple - value-inequality 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-op-3.rq
PREFIX :       <http://example/>

SELECT * {
  ?x :left ?left .
  ?x :right ?right .
  FILTER ( ?left < ?right )
  FILTER ( ?right > ?left )
}
Data: data-7.ttl
PREFIX : <http://example/>

:x1 :left  << :a :b 123 >> .
:x1 :right << :a :b 123.0 >> .

:x2 :left  << :a :b 123 >> .
:x2 :right << :a :b 123 >> .

:x3 :left  << << :a :b 123 >> :q 999 >> .
:x3 :right << << :a :b 123.0 >> :q 999 >> .

:x4 :left  << :a :b 123 >> .
:x4 :right << :c :d 123 >> .

:x5 :left  << _:bnode1 :b 123 >> .
:x5 :right << _:bnode1 :b 123 >> .

:x6 :left  << _:bnode2 :b 123e0 >> .
:x6 :right << _:bnode2 :b 123 >> .

:x7 :left  << :a :b 9 >> .
:x7 :right << :a :b 123 >> .


MUST result into
sparql-star-op-3.srj
{ "head": {
    "vars": [ "x" , "left" , "right" ]
  } ,
  "results": {
    "bindings": [
      { 
        "x": { "type": "uri" , "value": "http://example/x7" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "9" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Embedded triple - value-inequality 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-op-4.rq
PREFIX :       <http://example/>

SELECT * {
  ?x :left ?left .
  ?x :right ?right .
  FILTER ( ?left <= ?right )
  FILTER ( ?right >= ?left )
}
Data: data-7.ttl
PREFIX : <http://example/>

:x1 :left  << :a :b 123 >> .
:x1 :right << :a :b 123.0 >> .

:x2 :left  << :a :b 123 >> .
:x2 :right << :a :b 123 >> .

:x3 :left  << << :a :b 123 >> :q 999 >> .
:x3 :right << << :a :b 123.0 >> :q 999 >> .

:x4 :left  << :a :b 123 >> .
:x4 :right << :c :d 123 >> .

:x5 :left  << _:bnode1 :b 123 >> .
:x5 :right << _:bnode1 :b 123 >> .

:x6 :left  << _:bnode2 :b 123e0 >> .
:x6 :right << _:bnode2 :b 123 >> .

:x7 :left  << :a :b 9 >> .
:x7 :right << :a :b 123 >> .


MUST result into
sparql-star-op-4.srj
{ "head": {
    "vars": [ "x" , "left" , "right" ]
  } ,
  "results": {
    "bindings": [
      { 
        "x": { "type": "uri" , "value": "http://example/x7" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "9" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x2" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x1" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/a" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#decimal" , "value": "123.0" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x5" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b0" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x3" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/a" } ,
                "predicate": { "type": "uri" , "value": "http://example/b" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example/q" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example/a" } ,
                "predicate": { "type": "uri" , "value": "http://example/b" } ,
                "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#decimal" , "value": "123.0" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example/q" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        }
      } ,
      { 
        "x": { "type": "uri" , "value": "http://example/x6" } ,
        "left": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b1" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#double" , "value": "123e0" }
          }
        } ,
        "right": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "bnode" , "value": "b1" } ,
            "predicate": { "type": "uri" , "value": "http://example/b" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        }
      }
    ]
  }
}

SPARQL-star - Embedded triple - ORDER BY 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-order-by.rq
PREFIX : <http://example.com/>

SELECT *
WHERE {
   # Record ORDER BY for up to 20 items.
   # Each clause slices one ?v and sets ?index.
   # ?index is a unique string which is not in the same order.
   {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 0 LIMIT 1 }
     BIND( "B-1" as ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 1 LIMIT 1 }
     BIND( "B-2" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 2 LIMIT 1 }
     BIND( "A-3" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 3 LIMIT 1 }
     BIND( "C-4" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 4 LIMIT 1 }
     BIND( "B-5" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 5 LIMIT 1 }
     BIND( "B-6" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 6 LIMIT 1 }
     BIND( "C-7" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 7 LIMIT 1 }
     BIND( "C-8" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 8 LIMIT 1 }
     BIND( "A-9" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 9 LIMIT 1 }
     BIND( "C-10" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 10 LIMIT 1 }
     BIND( "C-11" as ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 11 LIMIT 1 }
     BIND( "A-12" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 12 LIMIT 1 }
     BIND( "B-13" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 13 LIMIT 1 }
     BIND( "A-14" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 14 LIMIT 1 }
     BIND( "B-15" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 15 LIMIT 1 }
     BIND( "C-16" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 16 LIMIT 1 }
     BIND( "C-17" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 17 LIMIT 1 }
     BIND( "B-18" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 18 LIMIT 1 }
     BIND( "A-19" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 19 LIMIT 1 }
     BIND( "A-20" AS ?index )
   }
}
Data: data-order-kind.ttl
PREFIX : <http://example/>

# The different kinds of orderable items.
# (Not in collation order).

:item :p :x .

:item :p << :s :p :o >> .

:item :p "abc" .

:item :p _:b .

##     (Lowest) no value assigned to the variable or expression in this solution.
##     Blank nodes
##     IRIs
##     RDF literals
##     RDF-star embedded triple terms
MUST result into
sparql-star-order-1.srj
{ "head": {
    "vars": [ "v" , "index" ]
  } ,
  "results": {
    "bindings": [
      { 
        "v": { "type": "bnode" , "value": "b0" } ,
        "index": { "type": "literal" , "value": "B-1" }
      } ,
      { 
        "v": { "type": "uri" , "value": "http://example/x" } ,
        "index": { "type": "literal" , "value": "B-2" }
      } ,
      { 
        "v": { "type": "literal" , "value": "abc" } ,
        "index": { "type": "literal" , "value": "A-3" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example/s" } ,
            "predicate": { "type": "uri" , "value": "http://example/p" } ,
            "object":   { "type": "uri" , "value": "http://example/o" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-4" }
      }
    ]
  }
}

SPARQL-star - Embedded triple - ordering 🔗

status:proposed
type:QueryEvaluationTest
Query: sparql-star-order-by.rq
PREFIX : <http://example.com/>

SELECT *
WHERE {
   # Record ORDER BY for up to 20 items.
   # Each clause slices one ?v and sets ?index.
   # ?index is a unique string which is not in the same order.
   {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 0 LIMIT 1 }
     BIND( "B-1" as ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 1 LIMIT 1 }
     BIND( "B-2" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 2 LIMIT 1 }
     BIND( "A-3" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 3 LIMIT 1 }
     BIND( "C-4" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 4 LIMIT 1 }
     BIND( "B-5" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 5 LIMIT 1 }
     BIND( "B-6" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 6 LIMIT 1 }
     BIND( "C-7" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 7 LIMIT 1 }
     BIND( "C-8" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 8 LIMIT 1 }
     BIND( "A-9" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 9 LIMIT 1 }
     BIND( "C-10" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 10 LIMIT 1 }
     BIND( "C-11" as ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 11 LIMIT 1 }
     BIND( "A-12" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 12 LIMIT 1 }
     BIND( "B-13" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 13 LIMIT 1 }
     BIND( "A-14" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 14 LIMIT 1 }
     BIND( "B-15" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 15 LIMIT 1 }
     BIND( "C-16" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 16 LIMIT 1 }
     BIND( "C-17" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 17 LIMIT 1 }
     BIND( "B-18" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 18 LIMIT 1 }
     BIND( "A-19" AS ?index )
   } UNION {
     { SELECT ?v { ?s ?p ?v } ORDER BY ?v OFFSET 19 LIMIT 1 }
     BIND( "A-20" AS ?index )
   }
}
Data: data-order.ttl
PREFIX :        <http://example.com/>

# Items that can be ordered
# The test query deals with up to 20 items.
# The integer in the subject does not correspond to expected order.

:s-01 :p <<:s :p 123>> .
:s-02 :p <<:s :p -456>> .

:s-03 :p _:blank-node .

:s-04 :p <<:s2 :p 900>> .
:s-05 :p <<:s1 :p 999>> .
:s-06 :p <<:s1 :a 999>> .

:s-07  :p "string" .

:s-08 :p << <<:x :y :z >> :q :r >> .
:s-09 :p << :s :p <<:x :y :z>> >> .
:s-10 :p << <<:x :y :z>> :q <<:x :y :z>> >> .

:s-11 :p << <<:s1 :a :o>> :q :r >> .

:s-12 :p <http://host/entity> .


MUST result into
sparql-star-order-2.srj
{ "head": {
    "vars": [ "v" , "index" ]
  } ,
  "results": {
    "bindings": [
      { 
        "v": { "type": "bnode" , "value": "b0" } ,
        "index": { "type": "literal" , "value": "B-1" }
      } ,
      { 
        "v": { "type": "uri" , "value": "http://host/entity" } ,
        "index": { "type": "literal" , "value": "B-2" }
      } ,
      { 
        "v": { "type": "literal" , "value": "string" } ,
        "index": { "type": "literal" , "value": "A-3" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/p" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "-456" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-4" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/p" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" }
          }
        } ,
        "index": { "type": "literal" , "value": "B-5" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/p" } ,
            "object":   {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example.com/x" } ,
                "predicate": { "type": "uri" , "value": "http://example.com/y" } ,
                "object":   { "type": "uri" , "value": "http://example.com/z" }
              }
            }
          }
        } ,
        "index": { "type": "literal" , "value": "B-6" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s1" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/a" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-7" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s1" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/p" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "999" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-8" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  { "type": "uri" , "value": "http://example.com/s2" } ,
            "predicate": { "type": "uri" , "value": "http://example.com/p" } ,
            "object":   { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "900" }
          }
        } ,
        "index": { "type": "literal" , "value": "A-9" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example.com/s1" } ,
                "predicate": { "type": "uri" , "value": "http://example.com/a" } ,
                "object":   { "type": "uri" , "value": "http://example.com/o" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example.com/q" } ,
            "object":   { "type": "uri" , "value": "http://example.com/r" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-10" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example.com/x" } ,
                "predicate": { "type": "uri" , "value": "http://example.com/y" } ,
                "object":   { "type": "uri" , "value": "http://example.com/z" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example.com/q" } ,
            "object":   { "type": "uri" , "value": "http://example.com/r" }
          }
        } ,
        "index": { "type": "literal" , "value": "C-11" }
      } ,
      { 
        "v": {
          "type": "triple" , 
          "value": {
            "subject":  {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example.com/x" } ,
                "predicate": { "type": "uri" , "value": "http://example.com/y" } ,
                "object":   { "type": "uri" , "value": "http://example.com/z" }
              }
            } ,
            "predicate": { "type": "uri" , "value": "http://example.com/q" } ,
            "object":   {
              "type": "triple" , 
              "value": {
                "subject":  { "type": "uri" , "value": "http://example.com/x" } ,
                "predicate": { "type": "uri" , "value": "http://example.com/y" } ,
                "object":   { "type": "uri" , "value": "http://example.com/z" }
              }
            }
          }
        } ,
        "index": { "type": "literal" , "value": "A-12" }
      }
    ]
  }
}

SPARQL-star - Update 🔗

status:proposed
type:UpdateEvaluationTest
Request: sparql-star-update-1.ru
PREFIX :       <http://example/>

INSERT {
  << ?s ?p ?o >> :source ?g
} WHERE {
  GRAPH ?g { ?s ?p ?o }
}
Data: data-6.trig
PREFIX :       <http://example/>

GRAPH :g1 { :s1 :p1 :o1 }
GRAPH :g2 { :s2 :p2 :o2 }
MUST result into
update-result-1.trig
PREFIX :       <http://example/>

GRAPH :g1 { :s1 :p1 :o1 }
GRAPH :g2 { :s2 :p2 :o2 }

<< :s2 :p2 :o2 >> :source :g2 .
<< :s1 :p1 :o1 >> :source :g1 .

SPARQL-star - Update - annotation 🔗

status:proposed
type:UpdateEvaluationTest
Request: sparql-star-update-2.ru
PREFIX :       <http://example/>

DELETE { GRAPH ?g { ?s ?p ?o } }
INSERT { ?s ?p ?o {| :source ?g |} }
WHERE {
  GRAPH ?g { ?s ?p ?o }
}
Data: data-6.trig
PREFIX :       <http://example/>

GRAPH :g1 { :s1 :p1 :o1 }
GRAPH :g2 { :s2 :p2 :o2 }
MUST result into
update-result-2.trig
PREFIX : <http://example/>

:s1 :p1 :o1 .
:s2 :p2 :o2 .
<< :s1 :p1 :o1 >> :source :g1 .
<< :s2 :p2 :o2 >> :source :g2.

SPARQL-star - Update - data 🔗

status:proposed
type:UpdateEvaluationTest
Request: sparql-star-update-3.ru
PREFIX :       <http://example/>

INSERT DATA {
   :s :p :o {| :source :faraway |}
}
;
DELETE DATA { :s :p :o }
Data: empty.nq

MUST result into
update-result-3.trig
<< <http://example/s> <http://example/p> <http://example/o> >>
        <http://example/source>  <http://example/faraway> .