Skip to content

Commit

Permalink
feat: anchor for non-ordinal reference to PlanRel
Browse files Browse the repository at this point in the history
This adds an "anchor" to `PlanRel` that can be referenced from a
`ReferenceRel`. This anchor and reference relationship provides a
non-ordinal method for identifying and accessing a "subtree" or
sub-graph.

This commit leaves in the original `subtree_ordinal` attribute since it
seems a (mildly) more performant method for referencing a subtree, but
also since it is still relevant in the typical case. The new anchor
improves cases where multiple plans are merged and at least one
already contains a `ReferenceRel`.

It is expected that only one of `subtree_ordinal` or `subtree_reference`
will be used, however I don't see a good reason to enforce the use of
only one, so I did not group the attributes in a `oneof` constraint.

Issue: #725
  • Loading branch information
drin committed Oct 25, 2024
1 parent 683f417 commit c0906f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion proto/substrait/algebra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,12 @@ message AggregateFunction {
}
}

// This rel is used to create references,
// This rel is used to create references,
// in case we refer to a RelRoot field names will be ignored
message ReferenceRel {
// points to a PlanRel in Plan.relations (ordinal reference)
int32 subtree_ordinal = 1;

// points to a subtree_anchor in PlanRel (for non-ordinal reference)
uint32 subtree_reference = 2;
}
3 changes: 3 additions & 0 deletions proto/substrait/plan.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ message PlanRel {
// The root of a relation tree
RelRoot root = 2;
}

// provides a non-ordinal anchor for ReferenceRel
uint32 subtree_anchor = 3;
}

// Describe a set of operations to complete.
Expand Down

0 comments on commit c0906f7

Please sign in to comment.