You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
117
116
118
-
```sql
117
+
```sql title="Query"
119
118
SELECT toTypeName(_full_document.customer_id) AS type FROM t1;
120
119
```
121
120
122
-
Result:
123
-
```shell
121
+
```shell title="Result"
124
122
┌─type────┐
125
123
│ Dynamic │
126
124
└─────────┘
127
125
```
128
126
129
127
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:
130
128
131
-
```sql
129
+
```sql title="Query"
132
130
SELECT dynamicType(_full_document.customer_id) AS type FROM t1;
133
131
```
134
132
135
-
Result:
136
-
```shell
133
+
```shell title="Result"
137
134
┌─type──┐
138
135
│ Int64 │
139
136
└───────┘
@@ -142,40 +139,40 @@ Result:
142
139
[Regular functions](https://clickhouse.com/docs/sql-reference/functions/regular-functions) work for dynamic type just like they do for regular columns:
143
140
144
141
**Example 1: Date parsing**
145
-
```sql
142
+
143
+
```sql title="Query"
146
144
SELECT parseDateTimeBestEffortOrNull(_full_document.order_date) AS order_date FROM t1;
0 commit comments