feat: add anchor for non-ordinal plan reference #726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds an "anchor" to
PlanRel
that can be referenced from aReferenceRel
. This anchor and reference relationship provides a non-ordinal method for identifying and accessing a "subtree" or sub-graph. To maintain consistency withtype_anchor
andfunction_anchor
, the newsubtree_anchor
attribute isuint32
.This PR 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 attribute is an improvement for cases where multiple plans are merged and at least one already contains aReferenceRel
.It is expected that only one of
subtree_ordinal
orsubtree_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 aoneof
constraint.If either of the above points ((1) keeping
subtree_ordinal
and (2) not enforcing aoneof
constraint) are changed, then this PR would likely become a breaking change.Also, this PR addresses #725 , but uses the name
subtree_reference
andsubtree_anchor
(instead ofplan_anchor
) to be consistent with the pre-existingsubtree_ordinal
attribute. I don't know that relations in a substrait plan are strictly trees, so I think this could be a good time to change "subtree" to "planrel" or "subgraph" or something similar.