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

a new method of ProposedNew set comparison #32563

Merged
merged 1 commit into from Jan 25, 2023

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jan 23, 2023

The existing ProposedNew set comparison method uses the prior elements with the computed portions nulled out to find candidates to match the configuration. This has the shortcoming of always removing optional+computed attributes, because we have not yet found the configuration to know if attribute was set or not.

Rather than having to take the most pessimistic value before comparison to precompute the nulled values, we can compare each candidate config and prior pair directly, walking the values in tandem. Each prior value is compared against the config and checked to see if it could have been derived from that configuration value, which allows us to treat optional+computed as optional if there is config and computed if there is not.

This removes the ambiguity from having optional+computed attributes within sets, giving us consistent plans when all values are known. Unknown values of course are still undecidable, as are edge cases were providers refresh with altered values or retained changed prior values plan that were deemed not functionally significant. We also cannot descend into nested sets, not only because the combinatorial problem of matching all possible nested values, but because we can't lookup nested blocks by paths nor can we use path.Apply when indexing through sets. The latter problems are possible to solve, through refactoring the schema and temporarily restructuring the set elements for comparison, but unless a compelling use case for such a structure arises the additional complexity has little benefit.

The existing set comparison method uses the prior elements with the computed
portions nulled out to find candidates to match the configuration. This
has the shortcoming of always removing optional+computed attributes,
because we have not yet found the configuration to know if attribute was
set or not.

Rather than having to take the most pessimistic value before comparison
to precompute the nulled values, we can compare each candidate directly,
walking the values in tandem. Each prior value is compared against the
config and checked to see if it could have been derived from that
configuration value, which allows us to treat optional+computed as
optional if there is config and computed if there is not.

This removes the ambiguity from having optional+computed attributes
within sets, giving us consistent plans when all values are known.
Unknown values of course are still undecidable, as are edge cases were
providers refresh with altered values or retained changed prior values
plan that were deemed not functionally significant.
Copy link
Member

@alisdair alisdair left a comment

Choose a reason for hiding this comment

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

This is a neat idea! It took me a long time to comprehend the walk callback, but I'm pretty confident I understand it now, and I can't think of any way of improving the comments that would've helped me get there faster.

Base automatically changed from jbardin/optional-computed-comparison to main January 25, 2023 20:05
@jbardin jbardin merged commit b6906f3 into main Jan 25, 2023
@jbardin jbardin deleted the jbardin/optional-computed-comparison-next branch January 25, 2023 20:05
@github-actions
Copy link

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants