I think that in terms of writing/reading queries, the coalesce/Union/identity pattern can get pretty cumbersome. As you guys mentioned, I think it would be good to have a simpler way to write this logic, regardless of the actual steps it compiles to.
Just throwing an idea out there, how about an "emit()" step that can be used anywhere? I think it would better explain what's going on than "optional(traversal)". For example: g. V().out().emit().choose(...).emit().whatever(...).emit() Any path that doesn't continue after the emit() would be returned, anything else would keep on going until the next emit() or the end of the traversal. On יום ב׳, 1 בפבר׳ 2016 at 21:25 pieter martin (JIRA) <j...@apache.org> wrote: > > [ > https://issues.apache.org/jira/browse/TINKERPOP-968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15126856#comment-15126856 > ] > > pieter martin commented on TINKERPOP-968: > ----------------------------------------- > > Ok great, > > The {{coalesce}} indeed does what I am looking for. > All that remains is whether its a good idea to add the {{optional}} > keyword anyways and compile that to a {{coalesce}} > > I would argue that it is worth it as I certainly have read the > {{coalesce}} docs before without understanding it. Considering the > TinkerPop crew also forgot that {{coalesce}} together with {{identity}} is > equivalent to {{optional}} perhaps it would make life easier if > {{optional}} gets first class status? > Its also somewhat shorter as there would be no need for the {{identity}} > traversal. > > Thanks > Pieter > > > Add first class support for an optional traversal > > ------------------------------------------------- > > > > Key: TINKERPOP-968 > > URL: https://issues.apache.org/jira/browse/TINKERPOP-968 > > Project: TinkerPop > > Issue Type: Improvement > > Components: process > > Affects Versions: 3.1.0-incubating > > Reporter: pieter martin > > > > Both SparQL and Cypher use the "Optional" keyword to indicate an > optional traversal. SQL uses the "left join". > > Gremlin has no first class support for an optional traversal. It can be > achieved with the choose step but it is verbose, unintuitive and not what > the choose step is intended for. > > The benefits of optional traversals are many. In particular it makes it > trivial to load complete subgraphs/trees with one easy to read intuitive > gremlin statement. > > > > -- > This message was sent by Atlassian JIRA > (v6.3.4#6332) >