diff --git a/mc2mc/pkg/query/helper.go b/mc2mc/pkg/query/helper.go index bf6cceb..7182a48 100644 --- a/mc2mc/pkg/query/helper.go +++ b/mc2mc/pkg/query/helper.go @@ -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) ) diff --git a/mc2mc/pkg/query/helper_test.go b/mc2mc/pkg/query/helper_test.go index ec6e16d..714da11 100644 --- a/mc2mc/pkg/query/helper_test.go +++ b/mc2mc/pkg/query/helper_test.go @@ -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)) + }) +}