Repository navigation
Make parent_id_fields imply provided_id_fields - #7938
Conversation
Every parent ID field was also listed as a provided ID field. Parent ID fields now count as provided ID fields (ProvidedIDRules), the duplicate entries are gone, and the action-category exclusivity test rejects listing a field in both. Co-authored-by: Isaac <no-reply@databricks.com>
…elds imply them (#7938) Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…elds imply them (#7938) Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…elds imply them (#7938) Co-authored-by: Isaac <no-reply@databricks.com>
|
Commit: Regression test reportSelected 4 changed tests (limit=20, 0 not selected) 9 tests: regression=9 unreleased=0 coverage=0 failing=0
TestAccept/bundle/resources/schemas/recreate_interrupted/DMS=: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/schemas/recreate_out_of_band/DMS=: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/schemas/recreate_out_of_band/DMS=true: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/move_from_renamed_schema/DMS=/READPLAN=: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/move_from_renamed_schema/DMS=/READPLAN=1: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/move_from_renamed_schema/DMS=true/READPLAN=: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/move_from_renamed_schema/DMS=true/READPLAN=1: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/uppercase-name/DMS=: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): TestAccept/bundle/resources/volumes/uppercase-name/DMS=true: branch ✅ | main (c450460) ❌ | latest (v1.28.0) ❌main (c450460): latest (v1.28.0): |
There was a problem hiding this comment.
Automated review at bd45cdc. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.
This PR makes parent_id_fields count as provided ID fields through a new ProvidedIDRules() accessor, removes the duplicate YAML entries for schemas, volumes and registered models, and makes the exclusivity test reject a field listed in both places. The mechanics look right, and the changes to secrets and to the plan reason match the description. Before merging, I'd add a test for the secrets planning change and make the new unit test check the merge it is named for.
Questions
- With the
id_fieldcopies gone, every recreate or skip on a parent field now reportsreason: parent. That includes a volume moved to an unrelated schema (move_from_renamed_schema) and a case-only remote diff (uppercase-name), even though neither is caused by the parent. Next toparent_renamed, this reads as if the parent caused it. Should the YAML reason stayid_field, or become something likeparent_id_field, so plan output still says why? (non-blocking)
| } | ||
| localChange := !structdiff.IsEqual(ch.Old, ch.New) | ||
| if reason, ok := findMatchingRule(path, cfg.ProvidedIDFields); ok { | ||
| if reason, ok := findMatchingRule(path, cfg.ProvidedIDRules()); ok { |
There was a problem hiding this comment.
[nice to have] For secrets, catalog_name/schema_name are listed only under parent_id_fields, so this line now matches them before secrets.generated.yml's recreate_on_changes (spec:immutable) at line 596. A remote-only difference that recreated on base is now skipped, and a local change reports parent instead of spec:immutable. No secrets golden or unit test covers either case. Can you add an acceptance test that shows the plan for a local schema_name change (recreate) and a remote-only case difference (skip)?
|
|
||
| func TestProvidedIDRulesIncludeParentIDFields(t *testing.T) { | ||
| var fields []string | ||
| for _, rule := range GetResourceConfig("volumes").ProvidedIDRules() { |
There was a problem hiding this comment.
[nice to have] volumes has no provided_id_fields left, so this test would still pass if ProvidedIDRules returned only ParentIDFields. Can it use registered_models (name plus catalog_name/schema_name) so both halves of the merge are checked?
| return nil | ||
| } | ||
|
|
||
| // ProvidedIDRules returns the provided ID fields, the parent ID fields among them. |
There was a problem hiding this comment.
[nit] "the parent ID fields among them" reads like a filter that returns only the parent ones. How about: "ProvidedIDRules returns ProvidedIDFields followed by ParentIDFields: every field whose local change recreates the resource and whose remote-only difference is skipped (see classifyIDField)."
✅ Integration test reportCommit: bd45cdc
Top 6 slowest tests (at least 2 minutes):
|
There was a problem hiding this comment.
Automated review at bd45cdc. Each finding was verified against the code.
No blocking issues found. 3 non-blocking comment(s) and 1 question(s) below.
This PR makes parent_id_fields count as provided ID fields through a new ProvidedIDRules() accessor, removes the duplicate YAML entries for schemas, volumes and registered models, and switches the plan readers to the accessor. The refactor itself looks right. My main concern is that it changes secret planning, which is intended but untested: secrets now skip a remote-only catalog_name/schema_name difference where they used to recreate. The new unit test also can't tell whether the union is actually built, and there's an open question about the relabelled plan reason.
Questions
- Merging in
ParentIDFieldsalso carries over theirreason: parent. The UC-lowercasing skip involumes/uppercase-name/out.deploy.txtis now labelledparent, and so are the move-to-another-schema recreates. That sits close toReasonParentRenamed, which marks real parent renames. Isparentthe word you want users to see in the plan output, or should these keepid_field(or use something likeparent_id)? (non-blocking)
| } | ||
|
|
||
| // ProvidedIDRules returns the provided ID fields, the parent ID fields among them. | ||
| func (c *ResourceLifecycleConfig) ProvidedIDRules() []FieldRule { |
There was a problem hiding this comment.
[nice to have] secrets.yml lists catalog_name/schema_name only under parent_id_fields. At base, classifyIDField didn't match them, so they fell through to the generated recreate_on_changes (spec:immutable). A remote-only difference, such as config Main against a UC-lowercased remote main, recreated the secret. Now it is skipped, and a local change recreates with reason parent. reconcileIDFields in bundle/migrate/build_state.go also starts reconciling these fields for secrets. No golden under acceptance/bundle/resources/secrets changed. Can you add an acceptance case that plans a case-only remote difference on catalog_name (expect skip) and a real catalog_name change (expect recreate/parent)?
|
|
||
| func TestProvidedIDRulesIncludeParentIDFields(t *testing.T) { | ||
| var fields []string | ||
| for _, rule := range GetResourceConfig("volumes").ProvidedIDRules() { |
There was a problem hiding this comment.
[nice to have] volumes no longer has any provided_id_fields, so ProvidedIDRules() returns only ParentIDFields. An implementation that ignored ProvidedIDFields entirely would still pass. Can you use registered_models instead? It has name plus both parent fields, so the test checks the union the helper exists to build.
| return nil | ||
| } | ||
|
|
||
| // ProvidedIDRules returns the provided ID fields, the parent ID fields among them. |
There was a problem hiding this comment.
[nit] "the provided ID fields, the parent ID fields among them" can be read as returning only the parent fields. Suggest: "ProvidedIDRules returns ProvidedIDFields followed by ParentIDFields; a parent ID field is a provided ID field too and is not listed again under provided_id_fields."
Changes
Every field in
parent_id_fields(#7718) was also listed inprovided_id_fields. Parent ID fields now count as provided ID fields on their own, so the duplicate entries are gone from the schema, volume and registered model configs. The action-category exclusivity test now rejects a field listed in both.A plan that recreates on a parent field now shows
reason: parentinstead ofid_field. Secrets on main listcatalog_nameandschema_nameonly as parent ID fields, so these are now provided ID fields for secrets too: a local change still recreates, and a remote-only difference is skipped, as for volumes and models.Comes before #7379 in the stack; it and #7381 rebase on this one.
Tests
TestResourcesYMLActionCategoriesExclusiveincludesparent_id_fields.TestProvidedIDRulesIncludeParentIDFields.This pull request and its description were written by Isaac.