Repository: tobymao/sqlglot

Issue:
Support `and()`, `or()` functions (ClickHouse)
**Code snippets**

1)
```python
from sqlglot import dialects, parse_one

sql = 'select and(1, 2)'

parse_one(sql=sql, dialect=dialects.ClickHouse)
```
2)
```python
from sqlglot import dialects, parse_one

sql = 'select or(1, 2)'

parse_one(sql=sql, dialect=dialects.ClickHouse)
```

**Python** 3.11
**sqlglot** 26.6.0

**Expected**: successful parsing
**Actual**:

1)
```python
ParseError: Required keyword: 'this' missing for <class 'sqlglot.expressions.And'>. Line 1, Col: 16.
  select and(1, 2)
```
2) 
```python
ParseError: Required keyword: 'this' missing for <class 'sqlglot.expressions.Or'>. Line 1, Col: 15.
  select or(1, 2)
```

**Official Documentation**
1) https://clickhouse.com/docs/sql-reference/functions/logical-functions#and
2) https://clickhouse.com/docs/sql-reference/functions/logical-functions#or

Discussion:

Solution patch:
diff --git a/sqlglot/dialects/clickhouse.py b/sqlglot/dialects/clickhouse.py
index 2c346ba7a8..feb0dbc2d7 100644
--- a/sqlglot/dialects/clickhouse.py
+++ b/sqlglot/dialects/clickhouse.py
@@ -440,6 +440,8 @@ class Parser(parser.Parser):
 
         FUNC_TOKENS = {
             *parser.Parser.FUNC_TOKENS,
+            TokenType.AND,
+            TokenType.OR,
             TokenType.SET,
         }
 
diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py
index 8db777d4c4..72799be0f4 100644
--- a/sqlglot/expressions.py
+++ b/sqlglot/expressions.py
@@ -4852,14 +4852,6 @@ class Connector(Binary):
     pass
 
 
-class And(Connector):
-    pass
-
-
-class Or(Connector):
-    pass
-
-
 class BitwiseAnd(Binary):
     pass
 
@@ -5989,6 +5981,14 @@ class LowerHex(Hex):
     pass
 
 
+class And(Connector, Func):
+    pass
+
+
+class Or(Connector, Func):
+    pass
+
+
 class Xor(Connector, Func):
     arg_types = {"this": False, "expression": False, "expressions": False}
 


Test patch:
diff --git a/tests/dialects/test_clickhouse.py b/tests/dialects/test_clickhouse.py
index 978cde8621..37a6babb09 100644
--- a/tests/dialects/test_clickhouse.py
+++ b/tests/dialects/test_clickhouse.py
@@ -29,6 +29,8 @@ def test_clickhouse(self):
         self.assertEqual(expr.sql(dialect="clickhouse"), "COUNT(x)")
         self.assertIsNone(expr._meta)
 
+        self.validate_identity("SELECT 1 OR (1 = 2)")
+        self.validate_identity("SELECT 1 AND (1 = 2)")
         self.validate_identity("SELECT json.a.:Int64")
         self.validate_identity("SELECT json.a.:JSON.b.:Int64")
         self.validate_identity("WITH arrayJoin([(1, [2, 3])]) AS arr SELECT arr")
@@ -164,6 +166,14 @@ def test_clickhouse(self):
         self.validate_identity(
             "SELECT generate_series FROM generate_series(0, 10) AS g(x)",
         )
+        self.validate_identity(
+            "SELECT and(1, 2)",
+            "SELECT 1 AND 2",
+        )
+        self.validate_identity(
+            "SELECT or(1, 2)",
+            "SELECT 1 OR 2",
+        )
         self.validate_identity(
             "SELECT generate_series FROM generate_series(0, 10) AS g",
             "SELECT generate_series FROM generate_series(0, 10) AS g(generate_series)",