https://github.com/datadudes/json2hive
Generate Hive CREATE TABLE statements from json data
https://github.com/datadudes/json2hive
cli hive json
Last synced: about 1 year ago
JSON representation
Generate Hive CREATE TABLE statements from json data
- Host: GitHub
- URL: https://github.com/datadudes/json2hive
- Owner: datadudes
- Created: 2017-11-02T13:30:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-02T13:30:57.000Z (over 8 years ago)
- Last Synced: 2025-03-25T23:51:19.426Z (over 1 year ago)
- Topics: cli, hive, json
- Language: Python
- Size: 4.88 KB
- Stars: 10
- Watchers: 2
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
json2hive
=========
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:
.. code-block:: bash
$ pip install json2hive
It is **strongly recommended** that you install ``json2hive`` inside a `virtual environment`_!
.. _virtual environment: http://docs.python-guide.org/en/latest/dev/virtualenvs/
Usage
-----
**On the Command Line**
Run the following and follow the instructions:
.. code-block:: bash
$ json2hive --help
**As a library**
.. code-block:: python
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)