Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get result format JSON from Athena in AWS?

I want to get result value format JSON from Athena in AWS.

When I select from the Athena then the result format like this.

{test.value={report_1=test, report_2=normal, report_3=hard}}

Is there any way to get JSON format result without replacing "=" to ":" ?

The column format is

map<string,map<string,string>>
like image 703
Bethlee Avatar asked Dec 07 '22 18:12

Bethlee


1 Answers

select  mycol
from    mytable
;

+--------------------------------------------------------------+
|                            mycol                             |
+--------------------------------------------------------------+
| {test.value={report_3=hard, report_2=normal, report_1=test}} |
+--------------------------------------------------------------+

select  cast (mycol as json) as json
from    mytable
;

+--------------------------------------------------------------------------+
|                                   json                                   |
+--------------------------------------------------------------------------+
| {"test.value":{"report_1":"test","report_2":"normal","report_3":"hard"}} |
+--------------------------------------------------------------------------+
like image 134
David דודו Markovitz Avatar answered Dec 19 '22 22:12

David דודו Markovitz