Skip to content

Commit ac45f5e

Browse files
committed
Casting
1 parent 6ee4993 commit ac45f5e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/ws/examples.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,20 @@ LIMIT 1;
203203

204204
!!! note "Typing"
205205

206-
If demographics.age was of type Long, then Bullet will convert 85 to be an Long, but in this example, we are pretending that it is String. So, no conversion is made. Similarly for link_id, id, experience and page_id. tags is a Map of String to Boolean so Bullet converts ```"true"``` to the Boolean ```true```. Till we support casting ([#37](https://github.com/bullet-db/bullet-core/issues/37)), this will be the behavior automatically enforced by Bullet.
206+
If demographics.age was of type Long, then Bullet will convert 85 to be an Long, but in this example, we are pretending that it is String. So, no conversion is made. Similarly for link_id, id, experience and page_id. tags is a Map of String to Boolean so Bullet converts ```"true"``` to the Boolean ```true```. See below on how to rewrite it with casting.
207+
208+
209+
#### Logical Filters and Projections with Casting
210+
211+
```SQL
212+
SELECT id AS id, experience AS experience, page_id AS pid,
213+
link_id AS lid, tags AS tags, CAST(demographics.age AS LONG) AS age
214+
FROM STREAM(60000, TIME)
215+
WHERE (id = 'c14plm1begla7' AND ((experience = 'web' AND page_id IN ['18025', '47729'])
216+
OR link_id RLIKE '2.*'))
217+
OR (tags.player = 'true' AND CAST(demographics.age AS LONG) > 65L)
218+
LIMIT 1;
219+
```
207220

208221
This query is looking for a single event with a specific id and either the page_id is in two specific pages on the "web" experience or with a link_id that starts with 2, or a player event where the age is greater than "65". In other words, it is looking for senior citizens who generate video player events or the events of a particular person (based on id) events on two specific pages or a group of pages that have link that have ids that start with 2. It then projects out only these fields with different names.
209222

@@ -217,7 +230,7 @@ A sample result could look like (it matched because of tags.player was true and
217230
"id":"0qcgofdbfqs9s",
218231
"experience":"web",
219232
"lid":"978500434",
220-
"age":"66",
233+
"age":66,
221234
"tags":{"player":true}
222235
}
223236
],

0 commit comments

Comments
 (0)