Page MenuHomePhabricator
Paste P7053

JSON_ARRAYAGG on terbium?
ActivePublic

Authored by Amire80 on Apr 30 2018, 10:04 AM.
Tags
None
Referenced Files
F17436855: JSON_ARRAYAGG on terbium?
Apr 30 2018, 10:48 AM
F17436476: JSON_ARRAYAGG on terbium?
Apr 30 2018, 10:05 AM
F17436401: JSON_ARRAYAGG on terbium?
Apr 30 2018, 10:04 AM
Subscribers
None
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, but if I try it, I get this error:
ERROR 1370 (42000): execute command denied to user 'research_prod'@'%' for routine 'log.JSON_ARRAYAGG'

Event Timeline

Amire80 edited the content of this paste. (Show Details)