Repository: tobymao/sqlglot

Issue:
sqlglot 20.8.0 incorrectly transpiles or fails to parse Snowflake REMOVE / RM syntax
Snowflake RM / REMOVE syntax is incorrectly transpiled or causes errors for the cases from the documentation: `"RM @parquet_stage;" -> "RM AS $parquet_stage;"` is rejected by Snowflake at runtime, the other cases cause ParseErrors.

## reference
https://docs.snowflake.com/en/sql-reference/sql/remove

## code
```
examples = [
    "RM @parquet_stage;",
    "REMOVE @parquet_stage;",
    "RM @%mytable/myobject;",
    "RM @%mytable/myobject/;",
    "RM @~ pattern='.*jun.*';",
    "REMOVE @%orders;",
    "REMOVE @mystage/path1/subpath2;",
]

import sqlglot
import sqlglot.errors

print(sqlglot.__version__)
for i, s in enumerate(examples):
    try:
        t = sqlglot.transpile(
            s.strip(), read="snowflake", write="snowflake", pretty=True
        )
        print(i, s, "->", t)
    except sqlglot.errors.ParseError as e:
        print(i, "error", e)
```
## output
```
20.8.0
0 RM @parquet_stage; -> ['RM AS $parquet_stage']
1 REMOVE @parquet_stage; -> ['REMOVE AS $parquet_stage']
2 error Required keyword: 'this' missing for <class 'sqlglot.expressions.Parameter'>. Line 1, Col: 5.
  RM @%mytable/myobject;
3 error Required keyword: 'this' missing for <class 'sqlglot.expressions.Parameter'>. Line 1, Col: 5.
  RM @%mytable/myobject/;
4 error Required keyword: 'this' missing for <class 'sqlglot.expressions.Parameter'>. Line 1, Col: 5.
  RM @~ pattern='.*jun.*';
5 error Required keyword: 'this' missing for <class 'sqlglot.expressions.Parameter'>. Line 1, Col: 9.
  REMOVE @%orders;
6 error Invalid expression / Unexpected token. Line 1, Col: 16.
  REMOVE @mystage/path1/subpath2;
```

Discussion:

Patch:
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py
index f88f3eb1..6ca8e9de 100644
--- a/sqlglot/dialects/snowflake.py
+++ b/sqlglot/dialects/snowflake.py
@@ -663,7 +663,9 @@ class Snowflake(Dialect):
             "MINUS": TokenType.EXCEPT,
             "NCHAR VARYING": TokenType.VARCHAR,
             "PUT": TokenType.COMMAND,
+            "REMOVE": TokenType.COMMAND,
             "RENAME": TokenType.REPLACE,
+            "RM": TokenType.COMMAND,
             "SAMPLE": TokenType.TABLE_SAMPLE,
             "SQL_DOUBLE": TokenType.DOUBLE,
             "SQL_VARCHAR": TokenType.VARCHAR,


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 1f365bea..5dd81cdc 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -39,6 +39,8 @@ WHERE
   )""",
         )
 
+        self.validate_identity("RM @parquet_stage")
+        self.validate_identity("REMOVE @parquet_stage")
         self.validate_identity("SELECT TIMESTAMP_FROM_PARTS(d, t)")
         self.validate_identity("SELECT GET_PATH(v, 'attr[0].name') FROM vartab")
         self.validate_identity("SELECT TO_ARRAY(CAST(x AS ARRAY))")