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

GMS tests have to resolve defaults #1952

Merged
merged 5 commits into from
Aug 22, 2023
Merged

Conversation

max-hoffman
Copy link
Contributor

@max-hoffman max-hoffman commented Aug 18, 2023

Force GMS to resolve column defaults, fix bugs exposed by additional testing. Dolt enginetests pass locally.

@max-hoffman max-hoffman marked this pull request as ready for review August 18, 2023 16:33
@max-hoffman max-hoffman requested a review from zachmu August 18, 2023 16:33
@nicktobey
Copy link
Contributor

Can we add tests to GMS for this? It's not immediately clear to me what the purpose of this change is, or what bugs it fixes. Tests would illustrate that.

newDef, _, _ := transform.Expr(cCopy.Default, func(e sql.Expression) (sql.Expression, transform.TreeIdentity, error) {
switch e := e.(type) {
case *expression.GetField:
return expression.NewGetField(e.Index(), e.Type(), e.Name(), e.IsNullable()), transform.NewTree, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this line? It looks like it just creates a new getField identical to the old one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have to serialize defaults without the table qualifier. I will add a comment

@max-hoffman
Copy link
Contributor Author

Can we add tests to GMS for this? It's not immediately clear to me what the purpose of this change is, or what bugs it fixes. Tests would illustrate that.

None of our column default expression tests were tested on the GMS side. So load data, alter table, show queries, insert/triggers, etc. This change makes all of our memory tests actually test resolving column defaults.

@max-hoffman
Copy link
Contributor Author

For a bit more context, the lifecycle of column defaults go through a serialization phase into and off disk. We write expression strings that represent default expressions that have to be individually parsed, resolved, and indexed. Managing this lifecycle is an additional hard step in many ALTER and DML statements. The GMS memory implementation was lazy and never serialized column defaults, making the GMS tests of column defaults trivially easy to pass. The Dolt implementation was our only layer of defaults testing. This PR forces the GMS memory tables to act as if they serialize column defaults, forcing us to test column defaults more heavily. The result was that several GMS-only tests broke, which were also gaps in Dolt's testing and correctness.

@max-hoffman max-hoffman merged commit c5eefe9 into main Aug 22, 2023
@max-hoffman max-hoffman deleted the max/gms-test-resolve-defaults branch August 22, 2023 15:56
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.

3 participants