Skip to main content

Identifique e gere querys para normalização de JSONs via AWS Athena

Project description

Nice

Ferramenta para facilitar a normalização de JSON's via Amazon Athena

Python Version

Getting Started

Nice é uma aplicação que tem como finalidade a identificação de possíveis tabelas em um JSON, gerando querys para sua normalização via Amazon Athena.

Installation

Instalar o pacote via PyPI:

pip install nice_parser

Usage

Gerar Query

I. Importar Módulos

from nice import MappingJson

II. Criar Query a partir de JSON, passando como parâmetro a origem de seu dado, o nome do database e da tabela

parser = MappingJson('path/sample.json', databaseName='database', tableName='table')
database = parser.parse()
query = database.createQuery()
query.Save('output.sql', database)

Um JSON com os seguintes valores:

{
   "shipping_address":{
      "province_code":"TX",
      "latitude":-87.561414
   },
   "buyer_accepts_marketing":true,
   "token":"a4b8c15d16e42",
   "total_weight":0,
   "line_items":[
      {
         "destination_location_id":4815162342,
         "requires_shipping":true,
         "variant_title":"rb_nice"
      }
   ]
}

Será convertido e disponibilizado em um arquivo .sql, como no exemplo abaixo:

/* ---------------------------------------------*
 * Descrição: Tabela Principal - tableName      *
 * ---------------------------------------------*/

 SELECT
  CAST("json_extract"(table, '$.shipping_address.province_code') AS VARCHAR) "shipping_address_province_code",
  CAST("json_extract"(table, '$.shipping_address.latitude') AS DECIMAL) "shipping_address_latitude",
  CAST("json_extract"(table, '$.buyer_accepts_marketing') AS BOOLEAN) "buyer_accepts_marketing",
  CAST("json_extract"(table, '$.token') AS VARCHAR) "token",
  CAST("json_extract"(table, '$.total_weight') AS BIGINT) "total_weight"
 FROM database.table

/* ---------------------------------------------*
 * Descrição: Tabela Secundária - tableName     *
 * ---------------------------------------------*/

 SELECT
  CAST("json_extract"("line_items", '$.destination_location_id') AS BIGINT) "destination_location_id",
  CAST("json_extract"("line_items", '$.requires_shipping') AS BOOLEAN) "requires_shipping",
  CAST("json_extract"("line_items", '$.variant_title') AS VARCHAR) "variant_title",
 FROM
  (database.table
 CROSS JOIN UNNEST(CAST("json_extract"(table, '$.line_items') AS array(json))) t (line_items))

...

Getting Help

Para bug report, perguntas ou solicitações, devem ser utilizadas as Issues do Bitbucket.

Contributing

Leia o documento CONTRIBUTING.md antes de enviar qualquer Issue ou Pull Request, garantindo assim, que tenhamos todas as informações necessárias para responder efetivamente à sua contribuição.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nice_parser-0.0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

nice_parser-0.0.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file nice_parser-0.0.2.tar.gz.

File metadata

  • Download URL: nice_parser-0.0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.0

File hashes

Hashes for nice_parser-0.0.2.tar.gz
Algorithm Hash digest
SHA256 eea27585be371885be72f40d471bf945453e3e7967c711769559def8c4fee9e4
MD5 499dfdc6bb6a2ce6b9e3ab55910c1877
BLAKE2b-256 2bbca7a1e2088432ef0934ecbccd963a94e858c081ebeb59106a88bc94a0c5fc

See more details on using hashes here.

File details

Details for the file nice_parser-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: nice_parser-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.0

File hashes

Hashes for nice_parser-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3695f443ef268ed9706f7823cfaaeee1e7b3f7fcbba07dbfbb35437e49a4dfaa
MD5 75f25074f9c901f83969934750184c2c
BLAKE2b-256 bb92922c5a30a8a71bd36cdec6b33a758de7cc7a38c1f2dcedfece37d2790924

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page