openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
864 stars 210 forks source link

how to use `t_end_flag` in `TRANSITIVE` clause? #945

Open zzqiang163 opened 3 years ago

zzqiang163 commented 3 years ago

Virtuoso SPARQL allows access to Virtuoso's SQL transitivity extension.

option (transitive transitivity_option[,...])

  transitivity_option ::=  t_in (<variable_list>)
  | t_out (<variable_list>)
  | t_distinct
  | t_shortest_only
  | t_no_cycles
  | t_cycles_only
  | t_min (INTNUM)
  | t_max (INTNUM)
  | t_end_flag (<variable>)
  | t_step (<variiable_or_step>)
  | t_direction INTNUM

  variable_list ::= <variable> [,...]

  variable_or_step ::= <variable> | path_id' | 'step_no' 

But don't give any description or sample about t_end_flag

please tell me something about this

Ztomepic commented 8 months ago

I have exactly the same question.

HughWilliams commented 8 months ago

T_END_FLAG (intnum) — This option is used to indicate that the transitive operation should stop when the variable returns a non-zero value. Its value is a positive integer indicating the ordinal position of the variable in the select list to be used.

Sample query showing its use:

SELECT ?syn
WHERE
  {
    {
      SELECT ?x ?syn
      WHERE
        {
          { ?x owl:sameAs ?syn }
          UNION
          { ?syn owl:sameAs ?x }
        }
    }
    OPTION (TRANSITIVE, t_in (?x), t_out (?syn), t_distinct, t_min (0), T_END_FLAG 2)
    FILTER (?x = <http://dbpedia.org/resource/New_York>) .
  }

Live Query Link ...