Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Generate Hive CREATE TABLE statements from json data

Project description

json2hive is a command line utility that can automatically generate CREATE TABLE statements for Hive tables backed by JSON data.

Features

  • Automatically infer schema of JSON data by analysing JSON records
  • Supports external and managed Hive tables
  • Can be used as command line utility or programmatically

Installation

You can install json2hive using pip:

$ pip install json2hive

It is strongly recommended that you install json2hive inside a virtual environment!

Usage

On the Command Line

Run the following and follow the instructions:

$ json2hive --help

As a library

from json2hive.utils import infer_schema
from json2hive.generators import generate_json_table_statement

# infer schema from objects, these objects could be the result of json.loads(...)
object1 = {'name': 'John', age: 25}
object2 = {'name': 'Mary', age: 23}
schema = infer_schema([object1, object2])

# Generate CREATE TABLE statement
statement = generate_json_table_statement('example', schema, managed=True)
print(statement)

Project details


Release history Release notifications

This version
History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
json2hive-0.1-py2.py3-none-any.whl (6.3 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Nov 2, 2017
json2hive-0.1.tar.gz (4.2 kB) Copy SHA256 hash SHA256 Source None Nov 2, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page