• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to fetch info from curly braces using Athena

Resolved: How to fetch info from curly braces using Athena

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am trying to fetch info using Athena, I don’t know much about the Athena service of AWS. Could anyone help me how to fetch this particular info i.e. “Attribute4”: “RSQ”. I am pasting a demo data in JSON format to give better understanding how the data is structured.
I will grateful if you could give explanation and any document that will help me to enrich my knowledge regarding Athena querying style.
{ "ID": "1234", "Name": "XYZ", "Age": "29", "address": { "street": "ABC", "houseno": "PRQ", "attributeDetails": { "Attribute1": "FGH", "Attribute2": "KLM", "Attribute3": "LMN", "Attribute4": "RSQ" }
Athena Query which I am trying to write
select ID, address.attributeDetails FROM “TableName”

Answer:

Athena is using Presto sql engine which has several functions to work with json, in this case you can use json_extract_scalar to get the id and json_extract for attributeDetails:
Output:
_col0 _col1
1234 {“Attribute1″:”FGH”,”Attribute2″:”KLM”,”Attribute3″:”LMN”,”Attribute4″:”RSQ”}

If you have better answer, please add a comment about this, thank you!

sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Azuer Service Bus SDK not receiving the specified messages

01/04/2023

Resolved: how to change date format from 201904 to Apr-19 in excel

01/04/2023

Resolved: Iterator for custom Hashtable C#

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.