Repository: tobymao/sqlglot

Issue:
Incorrect Handling of the `~~~` Operator in DuckDB
When testing SQLGlot with DuckDB, I discovered that the `~~~` operator is incorrectly handled. This operator is equivalent to the `GLOB` keyword in DuckDB, but SQLGlot incorrectly translates it.

#### Original Query:

```sql
SELECT ?::VARCHAR ~~~ ?::VARCHAR LIMIT 1
```

#### SQLGlot Output:

```sql
SELECT REGEXP_MATCHES(CAST(? AS TEXT), ~~CAST(? AS TEXT)) LIMIT 1
```

#### Expected Behavior:
SQLGlot should produce either the `~~~` operator or the `GLOB` function, as defined by DuckDB for pattern matching. The correct translation would be:

```sql
SELECT ?::VARCHAR ~~~ ?::VARCHAR LIMIT 1
```

#### Reference:
The `~~~` operator is documented to function the same as `GLOB` in DuckDB:
- [DuckDB Pattern Matching Documentation](https://duckdb.org/docs/sql/functions/pattern_matching.html)

Discussion:

Solution patch:
diff --git a/sqlglot/tokens.py b/sqlglot/tokens.py
index 29aa5c42d5..fd084d869a 100644
--- a/sqlglot/tokens.py
+++ b/sqlglot/tokens.py
@@ -649,6 +649,7 @@ class Tokenizer(metaclass=_Tokenizer):
         "<->": TokenType.LR_ARROW,
         "&&": TokenType.DAMP,
         "??": TokenType.DQMARK,
+        "~~~": TokenType.GLOB,
         "ALL": TokenType.ALL,
         "ALWAYS": TokenType.ALWAYS,
         "AND": TokenType.AND,


Test patch:
diff --git a/tests/dialects/test_duckdb.py b/tests/dialects/test_duckdb.py
index 5925789ed5..c9f4d62a4c 100644
--- a/tests/dialects/test_duckdb.py
+++ b/tests/dialects/test_duckdb.py
@@ -866,6 +866,7 @@ def test_duckdb(self):
         )
         self.validate_identity("a ^ b", "POWER(a, b)")
         self.validate_identity("a ** b", "POWER(a, b)")
+        self.validate_identity("a ~~~ b", "a GLOB b")
 
     def test_array_index(self):
         with self.assertLogs(helper_logger) as cm: