-
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
: multi-error in schema normalization
#12675
schemadiff
: multi-error in schema normalization
#12675
Conversation
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>
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>
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>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
…t views reading from DUAL 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>
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>
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>
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
… expression in DUAL 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>
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>
…-view-columns-semantics 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>
…lidateViewReferences 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>
go/vt/schemadiff/errors.go
Outdated
} | ||
|
||
// Unwrap unwraps an error created by errors.Join() in Go 1.20, into its components | ||
func Unwrap(err error) []error { |
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.
This method will not be called right. u.Unwrap on line 27 is called on object 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.
Right now no one is using this function... I added it for completeness.
@@ -153,6 +153,7 @@ func TestNewSchemaFromQueriesLoop(t *testing.T) { | |||
) | |||
_, err := NewSchemaFromQueries(queries) | |||
assert.Error(t, err) | |||
err = UnwrapOne(err) | |||
assert.EqualError(t, err, (&ViewDependencyUnresolvedError{View: "v7"}).Error()) |
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 assert err length here as well .. to assure the numbers of errors are as expected
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.
UnwrapOne()
is guaranteed to return a slice of at least one element.
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.
And yes! I'll add that assertion anyway.
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.
Rather, I'll create a errors_test.go
with a bunch of unit tests.
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.
Unit tests added
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
go/vt/schemadiff/errors.go
Outdated
// Wrapped is used to unwrap an error created by errors.Join() in Go 1.20 | ||
type Wrapped interface { |
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.
this is more a structural comment; i'd suggest either renaming or relocating these types. right now you import schemadiff.Wrapped
which, somehow, is for errors? i would expect from that name alone it's some sort of, well, wrapped diff structure (ditto the Unwrap*
functions).
so, i'd either advocate for schemadiff.WrappedError
or vterrors.Wrapped
(or a new package!)
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.
I agree. The location is suboptimal. I initially wanted to do this in vterrors
, but vterrors
has its own Unwrap
. I'll create a new errors
package.
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.
Done, refactored!
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
The logic added in vitessio#12675 has a small issue. When a view is found that has an error, it's not present anymore when a subsequent `.ToSQL()` call happens, so it looks like the view disappears. We should never have a view disappear since that could potentially break things and lead to unexpected results. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
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.
LGTM
The logic added in #12675 has a small issue. When a view is found that has an error, it's not present anymore when a subsequent `.ToSQL()` call happens, so it looks like the view disappears. We should never have a view disappear since that could potentially break things and lead to unexpected results. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Description
In this PR a
Schema
'snormalize()
function, which also runs validations for the entire schema, tables and views, returns a potentially aggregated error rather than a single error.The idea is to return as much information as possible about problems in the schema, we the user can have multiple action points they can handle at once. This is instead of receiving a single error, fixing it, trying again, receiving the next single error, etc.
Not all errors make sense to aggregate; we specifically aggregate errors that relate to view dependencies.
To top it all,
NewSchemaFromEntities()
returns whateverSchema
object it may have processed, even if invalid, as opposed to returningnil
on error.Related Issue(s)
#10203
Checklist
Deployment Notes