Skip to content

Commit f2e35e1

Browse files
committed
add title parameter to code blocks for nicer rendering of query and result blocks
1 parent ad918d5 commit f2e35e1

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

docs/integrations/data-ingestion/clickpipes/mongodb/quickstart.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,14 @@ FOR SELECT USING _peerdb_is_deleted = 0;
9797

9898
You can directly query JSON fields using dot syntax:
9999

100-
```sql
100+
```sql title="Query"
101101
SELECT
102102
_full_document.order_id,
103103
_full_document.shipping.method
104104
FROM t1;
105105
```
106106

107-
Result:
108-
```shell
107+
```shell title="Result"
109108
┌─_full_document.order_id─┬─_full_document.shipping.method─┐
110109
│ ORD-001234 │ express │
111110
└─────────────────────────┴────────────────────────────────┘
@@ -115,25 +114,23 @@ Result:
115114

116115
In ClickHouse, each field in JSON has `Dynamic` type. Dynamic type allows ClickHouse to store values of any type without knowing the type in advance. You can verify this with the `toTypeName` function:
117116

118-
```sql
117+
```sql title="Query"
119118
SELECT toTypeName(_full_document.customer_id) AS type FROM t1;
120119
```
121120

122-
Result:
123-
```shell
121+
```shell title="Result"
124122
┌─type────┐
125123
│ Dynamic │
126124
└─────────┘
127125
```
128126

129127
To examine the underlying data type(s) for a field, you can check with the `dynamicType` function. Note that it's possible to have different data types for the same field name in different rows:
130128

131-
```sql
129+
```sql title="Query"
132130
SELECT dynamicType(_full_document.customer_id) AS type FROM t1;
133131
```
134132

135-
Result:
136-
```shell
133+
```shell title="Result"
137134
┌─type──┐
138135
│ Int64 │
139136
└───────┘
@@ -142,40 +139,40 @@ Result:
142139
[Regular functions](https://clickhouse.com/docs/sql-reference/functions/regular-functions) work for dynamic type just like they do for regular columns:
143140

144141
**Example 1: Date parsing**
145-
```sql
142+
143+
```sql title="Query"
146144
SELECT parseDateTimeBestEffortOrNull(_full_document.order_date) AS order_date FROM t1;
147145
```
148146

149-
Result:
150-
```shell
147+
```shell title="Result"
151148
┌─order_date──────────┐
152149
│ 2025-08-19 20:32:11 │
153150
└─────────────────────┘
154151
```
155152

156153
**Example 2: Conditional logic**
157-
```sql
154+
155+
```sql title="Query"
158156
SELECT multiIf(
159157
_full_document.total_amount < 100, 'less_than_100',
160158
_full_document.total_amount < 1000, 'less_than_1000',
161159
'1000+') AS spendings
162160
FROM t1;
163161
```
164162

165-
Result:
166-
```shell
163+
```shell title="Result"
167164
┌─spendings──────┐
168165
│ less_than_1000 │
169166
└────────────────┘
170167
```
171168

172169
**Example 3: Array operations**
173-
```sql
170+
171+
```sql title="Query"
174172
SELECT length(_full_document.items) AS item_count FROM t1;
175173
```
176174

177-
Result:
178-
```shell
175+
```shell title="Result"
179176
┌─item_count─┐
180177
│ 2 │
181178
└────────────┘
@@ -192,12 +189,11 @@ SELECT sum(_full_document.shipping.cost) AS shipping_cost FROM t1;
192189

193190
To use aggregation functions, cast the field to the appropriate type with the `CAST` function or `::` syntax:
194191

195-
```sql
192+
```sql title="Query"
196193
SELECT sum(_full_document.shipping.cost::Float32) AS shipping_cost FROM t1;
197194
```
198195

199-
Result:
200-
```shell
196+
```shell title="Result"
201197
┌─shipping_cost─┐
202198
│ 19.99 │
203199
└───────────────┘

0 commit comments

Comments
 (0)