Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F17436476
JSON_ARRAYAGG on terbium?
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Amire80
Apr 30 2018, 10:05 AM
2018-04-30 10:05:29 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
JSON_ARRAYAGG on terbium?
View Options
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
Details
Attached
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)
Attached To
Mode
P7053 JSON_ARRAYAGG on terbium?
Attached
Detach File
Event Timeline
Log In to Comment