afs commented on code in PR #132:
URL: https://github.com/apache/jena-site/pull/132#discussion_r1030641717


##########
source/documentation/query/lateral-join.md:
##########
@@ -0,0 +1,174 @@
+---
+title: ARQ - Lateral Join
+---
+
+Lateral joins using the keyword `LATERAL` were introduced in Apache jena 4.7.0.
+
+A `LATERAL` join is like a foreach loop, looping on the results from the
+left-hand side (LHS), the pattern before the `LATERAL` keyword, and executing
+the right-hand side (RHS) query pattern once for each row, with the variables
+from the input LHS in-scope during each RHS evaluation.
+
+A regular join only executes the RHS once, and the variables from the LHS are
+used for the join condition after evaluation of the left and right
+sub-patterns.
+
+Another way to think of a lateral join is as a `flatmap`.
+
+Examples:
+```
+## Get exactly one label for each subject with type `:T`
+SELECT * {
+   ?s rdf:type :T
+   LATERAL {
+     SELECT * { ?s rdfs:label ?label } LIMIT 1
+   }
+}
+```
+
+```
+## Get zero or one labels for each subject.
+SELECT * {
+   ?s ?p ?o
+   LATERAL { OPTIONAL { SELECT * ?s rdfs:label ?label } LIMIT 1}
+   }
+}
+```
+
+#### Syntax
+
+The `LATERAL` keyword which takes the graph pattern so far in the group, from
+the `{` starting of the current block, and a `{ }` block afterwards.
+
+#### Evaluation
+
+[Substituting variables](https://afs.github.io/substitute.html) from the LHS 
into the RHS (with the same restrictions), then executing the pattern, gives 
the evaluation of `LATERAL`

Review Comment:
   Eventually!
   
   It is a better/fixed way to do EXISTS and LATERAL but Jena does not 
currently have a specific implementation.
   
   It's on my ToDo list.
   



##########
source/documentation/query/lateral-join.md:
##########
@@ -0,0 +1,174 @@
+---
+title: ARQ - Lateral Join
+---
+
+Lateral joins using the keyword `LATERAL` were introduced in Apache jena 4.7.0.
+
+A `LATERAL` join is like a foreach loop, looping on the results from the
+left-hand side (LHS), the pattern before the `LATERAL` keyword, and executing
+the right-hand side (RHS) query pattern once for each row, with the variables
+from the input LHS in-scope during each RHS evaluation.
+
+A regular join only executes the RHS once, and the variables from the LHS are
+used for the join condition after evaluation of the left and right
+sub-patterns.
+
+Another way to think of a lateral join is as a `flatmap`.
+
+Examples:
+```
+## Get exactly one label for each subject with type `:T`
+SELECT * {
+   ?s rdf:type :T
+   LATERAL {
+     SELECT * { ?s rdfs:label ?label } LIMIT 1
+   }
+}
+```
+
+```
+## Get zero or one labels for each subject.
+SELECT * {
+   ?s ?p ?o
+   LATERAL { OPTIONAL { SELECT * ?s rdfs:label ?label } LIMIT 1}
+   }
+}
+```
+
+#### Syntax
+
+The `LATERAL` keyword which takes the graph pattern so far in the group, from
+the `{` starting of the current block, and a `{ }` block afterwards.
+
+#### Evaluation
+
+[Substituting variables](https://afs.github.io/substitute.html) from the LHS 
into the RHS (with the same restrictions), then executing the pattern, gives 
the evaluation of `LATERAL`

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@jena.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to