-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
schemadiff: rich error for unmet view dependencies #10940
schemadiff: rich error for unmet view dependencies #10940
Conversation
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
@@ -239,3 +238,11 @@ func (e *InvalidColumnInForeignKeyConstraintError) Error() string { | |||
return fmt.Sprintf("invalid column %s referenced by foreign key constraint %s in table %s", | |||
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table)) | |||
} | |||
|
|||
type ViewDependencyUnresolvedError struct { | |||
View string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also here have a reference to the entity it tries to refer to? Like if a another table / view is missing, we'd also know the name here as well?
We could then further improve the error to "view %s references unknown entity %s" or something along those lines?
And maybe different from having a loop and have a separate error type for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the way we detect these dependencies is by creating a connected graph, and then looking at "what's outside the graph". We don't explicitly then check which tables/views are referenced by the left-out views. We could definitely do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbussink let's iterate on that in a followup PR though, if that's OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we can improve on a further iteration.
go/vt/schemadiff/schema.go
Outdated
return ErrViewDependencyUnresolved | ||
for _, v := range s.views { | ||
if _, ok := dependencyLevels[v.Name()]; !ok { | ||
// We _know_ that in this iteration, at least one view is found unassugned a dependency level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We _know_ that in this iteration, at least one view is found unassugned a dependency level. | |
// We _know_ that in this iteration, at least one view is found unassigned a dependency level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -239,3 +238,11 @@ func (e *InvalidColumnInForeignKeyConstraintError) Error() string { | |||
return fmt.Sprintf("invalid column %s referenced by foreign key constraint %s in table %s", | |||
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table)) | |||
} | |||
|
|||
type ViewDependencyUnresolvedError struct { | |||
View string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we can improve on a further iteration.
…itessio#959) * schemadiff: rich error for unmet view dependencies Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * grammar Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> * typo Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Description
This PR turns the flat
ErrViewDependencyUnresolved
error into a richerViewDependencyUnresolvedError
, indicating the identity of the view in question.Existing tests adapted to new error type.
Related Issue(s)
Checklist
Deployment Notes