Skip to content

Commit 2f6f2e8

Browse files
committed
Add Query with UDF
1 parent 03954c2 commit 2f6f2e8

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

README-zh.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ sess.query(
106106
print("Select from view:\n")
107107
print(sess.query("SELECT * FROM db_xxx.view_xxx", "Pretty"))
108108
```
109-
109+
110+
参见: [test_stateful.py](tests/test_stateful.py)
110111
</details>
111112

112113
<details>
@@ -126,6 +127,23 @@ conn1.close()
126127
```
127128
</details>
128129

130+
<details>
131+
<summary><h4>🗂️ Query with UDF(User Defined Functions)</h4></summary>
132+
133+
```python
134+
from chdb.udf import chdb_udf
135+
from chdb import query
136+
137+
@chdb_udf()
138+
def sum_udf(lhs, rhs):
139+
return int(lhs) + int(rhs)
140+
141+
print(query("select sum_udf(12,22)"))
142+
```
143+
144+
参见: [test_udf.py](tests/test_udf.py).
145+
</details>
146+
129147
更多示例,请参见 [examples](examples)[tests](tests)
130148

131149
## 演示和示例

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ sess.query(
111111
print("Select from view:\n")
112112
print(sess.query("SELECT * FROM db_xxx.view_xxx", "Pretty"))
113113
```
114-
114+
115+
see also: [test_stateful.py](tests/test_stateful.py).
115116
</details>
116117

117118
<details>
@@ -132,6 +133,23 @@ conn1.close()
132133
</details>
133134

134135

136+
<details>
137+
<summary><h4>🗂️ Query with UDF(User Defined Functions)</h4></summary>
138+
139+
```python
140+
from chdb.udf import chdb_udf
141+
from chdb import query
142+
143+
@chdb_udf()
144+
def sum_udf(lhs, rhs):
145+
return int(lhs) + int(rhs)
146+
147+
print(query("select sum_udf(12,22)"))
148+
```
149+
150+
see also: [test_udf.py](tests/test_udf.py).
151+
</details>
152+
135153
For more examples, see [examples](examples) and [tests](tests).
136154

137155
<br>

0 commit comments

Comments
 (0)