Skip to content

Commit 79b6935

Browse files
committed
feat: anchor for non-ordinal reference to PlanRel
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: substrait-io#725
1 parent 273f6ce commit 79b6935

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

proto/substrait/algebra.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,8 +1734,12 @@ message AggregateFunction {
17341734
}
17351735
}
17361736

1737-
// This rel is used to create references,
1737+
// This rel is used to create references,
17381738
// in case we refer to a RelRoot field names will be ignored
17391739
message ReferenceRel {
1740+
// points to a PlanRel in Plan.relations (ordinal reference)
17401741
int32 subtree_ordinal = 1;
1742+
1743+
// points to a subtree_anchor in PlanRel (for non-ordinal reference)
1744+
uint32 subtree_reference = 2;
17411745
}

proto/substrait/plan.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ message PlanRel {
1919
// The root of a relation tree
2020
RelRoot root = 2;
2121
}
22+
23+
// provides a non-ordinal anchor for ReferenceRel
24+
uint32 subtree_anchor = 3;
2225
}
2326

2427
// Describe a set of operations to complete.

0 commit comments

Comments
 (0)