Skip to content

GQ: optional traversals that preserve unmatched root rows #658

Description

@ragnorc

Problem

An ordinary traversal removes roots with no matching neighbor. There is no optional traversal construct to retain those roots and return nullable neighbor/edge bindings. Clients retrieving an entity with optional context need separate queries or client-side joins.

An attempted optional { ... } block fails parsing on 0.10.0; this is a requested language capability, not an existing syntax contract being violated.

Proposed change

Define optional match/traversal semantics with nullable bindings and clear variable scope. A root that matches the required portion should survive when the optional pattern has no match. Specify multiple matches, filters inside/outside the optional block, chained optional hops and interaction with aggregation/order/limit.

Acceptance criteria

  • Root rows with zero, one and multiple optional matches have documented multiplicity.
  • Nullability is reflected in compile-time result types/descriptors and JSON output.
  • Optional edge bindings expose properties only when the edge exists; parallel edges retain multiplicity.
  • Filters do not accidentally convert an optional traversal into a required one unless explicitly requested.
  • Indexed and scan execution produce the same rows, including empty graphs and self-loops.

Scope this issue to optional traversal. Nested maps/collections can be designed separately rather than making them prerequisites. Grammar, type checking, executor.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature proposalneeds-triageAwaiting maintainer triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions