New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

athena-struct-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

athena-struct-parser

Parser for AWS Athena's structs

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
448
34.13%
Maintainers
1
Weekly downloads
 
Created
Source

athena-struct-parser

A small utility to parse out structs returned by AWS Athena. Tools such as athena-express do a great job at querying Athena, however there's no easy way to get freeform JSON out of it. This tool allows one to parse the Athena's structs & Arrays into JS objects.

Problem

Let's take the following code as an example:

const results = await athenaExpress.query('SELECT struct, foo, bar FROM my_table');

// `results` is:
// {
//   "Items": [
//     {
//       "struct": "{foo=bar, baz=[{foe=moe}]}",
//       "foo": "baz",
//       "bar": zab
//     }
//   ]
// }

It's not easy to get the data out of that struct column, even if that's pretty common way to store data (as JSON blobs). One could try to use a rudimentary parser, but it might trip up on un-escaped characters.

Usage

Install the library via:

npm i athena-struct-parser
import parseStruct from 'athena-struct-parser';

const results = await athenaExpress.query('SELECT struct, foo, bar FROM my_table');

results.Items.map(result => {
  result.struct = parseStruct(result.struct);
  return result;
});

// `results.struct` now contains JS object with data from the struct:
// {
//   "Items": [
//     {
//       "struct": {
//         "foo": "bar",
//         "baz": [
//           {
//             "foe": "moe"
//           }
//         ]
//       }",
//       "foo": "baz",
//       "bar": zab
//     }
//   ]
// }

Keywords

athena

FAQs

Package last updated on 04 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts