Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make LinkabelElementSet non-optional in FilterSpecResolution #1176

Merged
merged 2 commits into from
May 6, 2024

Conversation

tlento
Copy link
Contributor

@tlento tlento commented May 3, 2024

The LinkableElementSet object is always present in the extant
initializer calls for FilterSpecResolution. This change allows
us to acces it without having to handle the Optional type everywhere,
and prevents future drift into mayhem as we inspect this object
for things like predicate pushdown evaluation.

@tlento tlento requested review from courtneyholcomb and plypaul May 3, 2024 23:30
@cla-bot cla-bot bot added the cla:yes label May 3, 2024
Copy link

github-actions bot commented May 3, 2024

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

specs = self.resolved_linkable_element_set.specs
if len(specs) == 0:
return None
elif len(specs) == 1:
return specs[0]
else:
raise RuntimeError(f"Found {len(specs)} in {self.resolved_linkable_element_set}")
raise ValueError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why we keep it typed as a LinkableElementSet instead of just a LinkableElement if there can only be one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is typed to return only one spec (or None) because that's historically what we've needed.

The LinkableElementSet we keep in the dataclass is there because the set maps the ElementPathKey (which is convertible to a LinkableInstanceSpec) to a collection of LinkableElement objects. This allows us to get the complete set of SemanticModel inputs for a given spec - like if a given Entity is sourced from multiple Semantic Models in the final joined query, that should be reflected here.

So we don't strictly need the LinkableElementSet, we can probably get away with extracting the spec and collection of LinkableElement objects, but the set is a little more convenient.

I think this utility becomes a little more obvious at a property access level with the remaining changes in the stack, but it might be worth an update to the dataclass docstring.

Base automatically changed from support-sets-pretty-printer to main May 6, 2024 17:27
The LinkableElementSet object is always present in the extant
initializer calls for FilterSpecResolution. This change allows
us to acces it without having to handle the Optional type everywhere,
and prevents future drift into mayhem as we inspect this object
for things like predicate pushdown evaluation.
@tlento tlento force-pushed the non-optional-linkable-set branch from c40e6b1 to 7c580e1 Compare May 6, 2024 17:29
Copy link
Contributor Author

tlento commented May 6, 2024

Merge activity

  • May 6, 3:51 PM PDT: @tlento started a stack merge that includes this pull request via Graphite.
  • May 6, 3:51 PM PDT: @tlento merged this pull request with Graphite.

@tlento tlento merged commit 907133e into main May 6, 2024
24 checks passed
@tlento tlento deleted the non-optional-linkable-set branch May 6, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants