Repository: tobymao/sqlglot

Issue:
Support BYTEINT in Snowflake dialect
Read dialect: snowflake

Looks like the Snowflake parser doesn't support BYTEINT when creating a table:

```
CREATE TABLE IF NOT EXISTS test_types (
    TEST_BIGINT BIGINT,
    TEST_INTEGER INTEGER,
    TEST_SMALLINT SMALLINT,
    TEST_FLOAT8 DOUBLE PRECISION,
    TEST_FLOAT4 REAL,
    TEST_BOOLEAN BOOLEAN,
    TEST_VARCHAR VARCHAR(100),
    TEST_STRING STRING,
    TEST_TEXT TEXT,
    TEST_CHAR CHAR(10),
    TEST_NVARCHAR NVARCHAR(100),
    TEST_NVARCHAR2 NVARCHAR(100),
    TEST_CHAR_VARYING CHAR VARYING(100),
    TEST_NCHAR_VARYING NCHAR VARYING(100),
    TEST_NCHAR NCHAR(100),
    TEST_CHARACTER CHARACTER(100),
    TEST_BINARY BINARY,
    TEST_VARBINARY VARBINARY,
    TEST_BLOB BLOB,
    TEST_DATE DATE,
    TEST_TIMESTAMP TIMESTAMP,
    TEST_DATETIME DATETIME,
    TEST_TIME TIME,
    TEST_DECIMAL DECIMAL(10,2),
    TEST_NUMERIC NUMERIC(10,2),
    TEST_NUMBER NUMBER(10,2),
    TEST_TINYINT TINYINT,
    TEST_BYTEINT BYTEINT
);
```

Gives me:

```
E           sqlglot.errors.ParseError: Expecting ). Line 30, Col: 40.
E             EST_NUMBER NUMBER(10,2),
E                               TEST_TINYINT TINYINT,
E                               TEST_BYTEINT BYTEINT
E                           );
```

Removing the TEST_BYTEINT line works.

BYTEINT is a valid type in Snowflake:

https://docs.snowflake.com/en/sql-reference/data-types-numeric#int-integer-bigint-smallint-tinyint-byteint


Discussion:

Resolving patch:
diff --git a/sqlglot/dialects/snowflake.py b/sqlglot/dialects/snowflake.py
--- a/sqlglot/dialects/snowflake.py
+++ b/sqlglot/dialects/snowflake.py
@@ -275,6 +275,7 @@ class Tokenizer(tokens.Tokenizer):
 
         KEYWORDS = {
             **tokens.Tokenizer.KEYWORDS,
+            "BYTEINT": TokenType.INT,
             "CHAR VARYING": TokenType.VARCHAR,
             "CHARACTER VARYING": TokenType.VARCHAR,
             "EXCLUDE": TokenType.EXCEPT,


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -23,19 +23,20 @@ def test_snowflake(self):
         self.validate_identity("CREATE TABLE foo (bar FLOAT AUTOINCREMENT START 0 INCREMENT 1)")
         self.validate_identity("ALTER TABLE IF EXISTS foo SET TAG a = 'a', b = 'b', c = 'c'")
         self.validate_identity("ALTER TABLE foo UNSET TAG a, b, c")
+        self.validate_identity("COMMENT IF EXISTS ON TABLE foo IS 'bar'")
+        self.validate_identity("SELECT CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', col)")
         self.validate_identity(
             'COPY INTO NEW_TABLE ("foo", "bar") FROM (SELECT $1, $2, $3, $4 FROM @%old_table)'
         )
-        self.validate_identity("COMMENT IF EXISTS ON TABLE foo IS 'bar'")
-        self.validate_identity("SELECT CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', col)")
 
+        self.validate_all("CAST(x AS BYTEINT)", write={"snowflake": "CAST(x AS INT)"})
         self.validate_all("CAST(x AS CHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
+        self.validate_all("CAST(x AS CHARACTER VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
+        self.validate_all("CAST(x AS NCHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
         self.validate_all(
             "SELECT * FROM (VALUES (0) foo(bar))",
             write={"snowflake": "SELECT * FROM (VALUES (0)) AS foo(bar)"},
         )
-        self.validate_all("CAST(x AS CHARACTER VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
-        self.validate_all("CAST(x AS NCHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
         self.validate_all(
             "OBJECT_CONSTRUCT(a, b, c, d)",
             read={