Skip to content

fix: order materialized-view creates by dependsOn (#41)#152

Open
alvarogar4 wants to merge 1 commit into
mainfrom
alvaro/chkit-mv-topo-order
Open

fix: order materialized-view creates by dependsOn (#41)#152
alvarogar4 wants to merge 1 commit into
mainfrom
alvaro/chkit-mv-topo-order

Conversation

@alvarogar4

Copy link
Copy Markdown
Member

Summary

  • Create operations within the same kind were tie-broken purely by name (key.localeCompare). A refreshable materialized view declared DEPENDS ON other_mv whose name sorts before its dependency could be created first and fail (audit finding docs: require bun verify before creating PRs #41).
  • The planner now derives a creation depth from refresh.dependsOn and orders a DEPENDS ON target before the view that depends on it. Independent views keep their stable alphabetical order; a dependency cycle falls back to name order rather than looping.

Test plan

  • New unit test (planner-mv-order.test.ts): two interdependent MVs whose names sort the wrong way are ordered dependency-first; independent MVs stay alphabetical.
  • Mutation-checked: reverting the fix makes the dependent sort first.
  • typecheck + lint pass.

Part of NUM-7318 (Tier-3 safety/resilience polish). 3 of 4: #41.

🤖 Generated with Claude Code

Create operations within the same kind were tie-broken purely by name
(key.localeCompare). A refreshable materialized view declared
`DEPENDS ON other_mv` whose name sorts before its dependency could be
created first and fail. The planner now derives a creation depth from
`refresh.dependsOn` and orders a DEPENDS ON target before the view that
depends on it; independent views keep their stable alphabetical order.
A dependency cycle falls back to the name order rather than looping.

Verified with a unit test of two interdependent MVs whose names sort the
wrong way (mutation-checked: dependent sorts first without the fix).

Refs NUM-7318.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vs5ZySdFPLkAz33L1TEEZk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant