Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contents/docs/data-warehouse/sql/data-access.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SELECT round(properties.$screen_width * properties.$screen_height / 1000000, 2)

This works because `$screen_width` and `$screen_height` are both defined as numeric properties. Thus you can multiply them.

To cast a string property into a different type, use type conversion functions, such as`toString`, `toDate`, `toFloat`, `JSONExtractString`, `JSONExtractInt`, and more.
To cast a string property into a different type, use type conversion functions, such as `toString`, `toDate`, `toFloat`, `toJSON`, `JSONExtractString`, `JSONExtractInt`, and more.

## Property access

Expand Down
7 changes: 7 additions & 0 deletions contents/docs/data-warehouse/sql/useful-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ select properties.$set.$geoip_country_name
from events
```

To convert a string property to the JSON type (useful for views where properties are stored as strings), use `toJSON()`:

```sql
SELECT toJSON(properties).some_field
FROM events
```

You can parse JSON with `JSONExtractRaw()` to return a value.

```sql
Expand Down
1 change: 1 addition & 0 deletions contents/docs/sql/clickhouse-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ If the function's name includes a leading underscore, then it's not safe and sim
- `toUUID`
- `toString`
- `toBool`
- `toJSON`
- `toJSONString`
- `toTypeName`
- `parseDateTime`
Expand Down