Skip to content

TraceQL: bare structural operators >, >>, <, << are rejected #986

Open

Description

@rita7lopes

What

TraceQL's four bare structural operators are rejected by reader/traceql/traceql_parser:

query result
{.a="x"} > {.b="y"} 1:10: unexpected token ">"
{.a="x"} >> {.b="y"} 1:10: unexpected token ">"
{.a="x"} < {.b="y"} 1:10: unexpected token "<"
{.a="x"} << {.b="y"} 1:10: unexpected token "<"

All four are valid TraceQL. From upstream Tempo:

  • pkg/traceql/lexer.go:27 — ">": GT, :53 — ">>": DESC, :54 — "<<": ANCE
  • pkg/traceql/expr.y:150-153 — GT → OpSpansetChild, LT → OpSpansetParent, DESC → OpSpansetDescendant, ANCE → OpSpansetAncestor

These are the child / descendant / parent / ancestor operators — core TraceQL, used in Grafana's own query builder. A user migrating from Tempo will hit this on their first structural query.

Reproduction

_, err := traceql_parser.Parse(`{.a="x"} >> {.b="y"}`)
// 1:10: unexpected token ">"

Sibling ~ parses fine, so the gap is specific to the child/descendant/parent/ancestor family.

Scope

Grammar and lexer only — reader/traceql/traceql_parser/lexer_rules.go and model.go. Transpiler support for the resulting spanset operations is separate and larger; this issue covers making them parse. Splitting is fine.

Credit

Found via @tsouza's parser-pin work in #925. The PR encoded these as negative test cases asserting the queries fail; verifying them against the upstream Tempo grammar showed they should succeed. Without that work these would have stayed invisible.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions