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

fix(spanddl): support dropping interleaved tables #501

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions spanddl/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestDatabase_ApplyDDL(t *testing.T) {
name string
ddls []string
expected *Database
errorDdlIndex int
errorContains string
}{
{
Expand Down Expand Up @@ -45,6 +46,23 @@ func TestDatabase_ApplyDDL(t *testing.T) {
},
},

{
name: "drop missing table",
ddls: []string{
`CREATE TABLE Singers (
SingerId INT64 NOT NULL,
FirstName STRING(1024),
LastName STRING(1024),
SingerInfo BYTES(MAX),
BirthDate DATE,
) PRIMARY KEY(SingerId);`,

`DROP TABLE Albums`,
},
errorDdlIndex: 1,
errorContains: "DROP TABLE: table Albums does not exist",
Copy link
Member Author

Choose a reason for hiding this comment

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

errorContains was unused before this pr.

},

{
name: "create table with row deletion policy",
ddls: []string{
Expand Down Expand Up @@ -356,13 +374,13 @@ func TestDatabase_ApplyDDL(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var db Database
for _, ddl := range tt.ddls {
for i, ddl := range tt.ddls {
ddl, err := spansql.ParseDDL(tt.name, ddl)
assert.NilError(t, err)
err = db.ApplyDDL(ddl)
if tt.errorContains != "" {
if tt.errorDdlIndex == i && tt.errorContains != "" {
assert.ErrorContains(t, err, tt.errorContains)
break
return
Copy link
Member Author

Choose a reason for hiding this comment

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

exit early if any ddl statement thrown an error

}
assert.NilError(t, err)
}
Expand Down