Skip to main content

Python API for unittest Hive applications

Project description

py-hiverunner

Build Status Code Coverage Status PyPI - Python Version Docker Build Status

Library provides python API for Klarna's HiveRunner.

Install

Install py-hiverunner package with pip:

$ python -m pip install py-hiverunner

Usage

Before using py-hiverunner you need start JVM with facade service based on original Klarna's HiveRunner - java-hiverunner. This repo provides docker container for Py4J Java Gateway for HiveRunner.

You can pull this:

$ docker pull la9ran9e/py-hiverunner

and then run the container:

$ docker run -ti -p 25333:25333 -p 25334:25334 la9ran9e/py-hiverunner

After that you will have working server with Java HiveRunner.

Try this:

from py_hiverunner import hiverunner
from pprint import pprint


with hiverunner() as hive:
    hive.execute_query("create schema meh")
    hive.execute_query("create table meh.nonsub(a int, b string, c array<string>)")
    hive.execute_query("insert into meh.nonsub select 1, 'la9ran9e', array('1', 'a', 'b', '6')")
    hive.execute_query("insert into meh.nonsub select 2, 'la9ran9e', array('1', 'b', 'b', '6')")
    hive.execute_query("insert into meh.nonsub select 3, 'la9ran9e', array('1', 'c', 'b', '6')")
    hive.execute_query("insert into meh.nonsub select 4, '', array('1', 'd', 'b', '6')")

    hive.execute_query("create table meh.sub(a int, b string, c boolean)")
    hive.execute_query("insert into meh.sub select 1, 'la9ran9e', true")

    print("RESULT:")
    pprint(hive.execute_query("""
        select
            *
        from
            meh.sub as sub
        inner join
            meh.nonsub as nonsub
        on
            sub.b = nonsub.b
    """))

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

py-hiverunner-0.1.3.tar.gz (5.4 kB view hashes)

Uploaded Source

Built Distribution

py_hiverunner-0.1.3-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

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