Page MenuHomePhabricator

JSON_ARRAYAGG on terbium?

Authored By
Amire80
Apr 30 2018, 10:05 AM
Size
1 KB
Referenced Files
None
Subscribers
None

JSON_ARRAYAGG on terbium?

I am doing something like this (this is not actual data; otherwise it would be private. I changed the values):
research_prod@db1108.eqiad.wmnet(log)>select
-> concat(wiki, ': ', event_title) as title,
-> event_token,
-> event_context
-> from
-> UniversalLanguageSelector_17799034
-> where
-> event_token = 'sdfs98df7s9d8f9s';
+------------------+------------------+---------------+
| title | event_token | event_context |
+------------------+------------------+---------------+
| enwiki: Moscow | sdfs98df7s9d8f9s | Armenian |
| enwiki: Moscow | sdfs98df7s9d8f9s | հա |
| enwiki: Moscow | sdfs98df7s9d8f9s | hayeren |
+------------------+------------------+---------------+
I'd like to get something like this:
+-------------------+------------------+-------------------------------+
| title | event_token | event_context |
+-------------------+------------------+-------------------------------+
| enwiki: Moscow | sdfs98df7s9d8f9s | ["Armenian", "հա", "hayeren"] |
+-------------------+------------------+-------------------------------+
The second is preferable because I need to do it for a lot of tokens, and to analyze the data from event_context for each of them.
Using GROUP_CONCAT is not great, because this is user input, and there is no safe way to concatenate it. JSON_ARRAYAGG should be safer.

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5783181
Default Alt Text
JSON_ARRAYAGG on terbium? (1 KB)

Event Timeline