Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion mc2mc/pkg/query/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
variablePattern = regexp.MustCompile(`(?i)^@`) // regex to match variable statements
dropPattern = regexp.MustCompile(`(?i)^DROP\s+`) // regex to match DROP statements
udfPattern = regexp.MustCompile(`(?i)^function\s+`) // regex to match UDF statements
ddlPattern = regexp.MustCompile(`(?i)^(ALTER|DROP|TRUNCATE)\s+`) // regex to match DDL statements
ddlPattern = regexp.MustCompile(`(?i)^(ALTER|DROP|TRUNCATE|PURGE)\s+`) // regex to match DDL statements
ddlCreatePattern = regexp.MustCompile(`(?i)^(CREATE\s+TABLE\s+[^\s]+\s*\()`) // regex to match CREATE DDL statements
stringPattern = regexp.MustCompile(`'[^']*'`) // regex to match SQL strings (anything inside single quotes)
)
Expand Down
7 changes: 7 additions & 0 deletions mc2mc/pkg/query/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,10 @@ func TestRestoreStringLiteral(t *testing.T) {
assert.Equal(t, `SELECT * FROM project.dataset.table WHERE name = 'john' AND age = 20 AND city = 'new york' AND address = '1234 5th --Ave';`, query)
})
}

func TestIsDDL(t *testing.T) {
t.Run("returns true for purge statement", func(t *testing.T) {
stmt := `PURGE TABLE project.dataset.table;`
assert.True(t, query.IsDDL(stmt))
})
}
Loading