Skip to main content

Python edition of RumbleDB, a JSONiq engine

Project description

RumbleDB for Python

by Abishek Ramdas and Ghislain Fourny

This is the Python version of RumbleDB. It is currently only a prototype (alpha) and probably unstable.

Install with

pip install jsoniq

Sample code:

from jsoniq import RumbleSession

# The syntax to start a session is similar to Spark.
rumble = RumbleSession.builder.appName("PyRumbleExample").getOrCreate();

# Create a data frame also similar to Spark (but using the rumble object).
data = [("Alice", 30), ("Bob", 25), ("Charlie", 35)];
columns = ["Name", "Age"];
df = rumble.createDataFrame(data, columns);

# This is how to bind a JSONiq variable to a dataframe. You can bind as many variables as you want.
rumble.bindDataFrameAsVariable('$a', df);

# This is how to run a query (declaring the external variable). This is similar to spark.sql().
res = rumble.jsoniq('declare variable $a external; $a.Name');

# returns a list containing one or several of "DataFrame", "RDD", "PUL", "Local"
modes = res.availableOutputs();

###### Parallel access ######

# This returns a regular data frame
df = res.getAsDataFrame();
df.show();

# This returns an RDD containing JSONiq item objects (does not work yet with transformations)
rdd = res.getAsRDD();
print(rdd.count());
for item in rdd.take(10):
    print(item.getStringValue());

##### Local access ######

# This materializes the rows as items.
# The items are access with the RumbleDB Item API.
list = res.getAsList();
for result in list:
    print(result.getStringValue())

# This streams through the items one by one
res.open();
while (res.hasNext()):
    print(res.next().getStringValue());
res.close();

###### Native Python/JSON Access for bypassing the Item API (but losing on the richer JSONiq type system) ######

# This method directly gets the result as JSON (dict, list, strings, ints, etc).
jlist = res.getAsJSONList();
for str in jlist:
    print(str);

# This streams through the JSON values one by one.
res.open();
while(res.hasNext()):
    print(res.nextJSON());
res.close();

# There is still a problem to solve to make RDDs work across Python and Java
#rdd = res.getAsJSONRDD();
#print(rdd.count());
#for str in rdd.take(10):
#    print(str);

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

jsoniq-0.1.0a5.tar.gz (25.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsoniq-0.1.0a5-py3-none-any.whl (25.5 MB view details)

Uploaded Python 3

File details

Details for the file jsoniq-0.1.0a5.tar.gz.

File metadata

  • Download URL: jsoniq-0.1.0a5.tar.gz
  • Upload date:
  • Size: 25.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jsoniq-0.1.0a5.tar.gz
Algorithm Hash digest
SHA256 8132322fd146bbc5cf1ab28bda48f90a7868530e5d581f18db4493cefe3bcf89
MD5 f9959a794d6cc892134a70179c094409
BLAKE2b-256 45037677499064046fbdc0a06c4ad873d714d5a36811def4055dbc9f6664143c

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsoniq-0.1.0a5.tar.gz:

Publisher: deploy.yml on RumbleDB/python-jsoniq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jsoniq-0.1.0a5-py3-none-any.whl.

File metadata

  • Download URL: jsoniq-0.1.0a5-py3-none-any.whl
  • Upload date:
  • Size: 25.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for jsoniq-0.1.0a5-py3-none-any.whl
Algorithm Hash digest
SHA256 da4383916206aa177d7a004437794d08011c95b558fe99f216b1be1abbc073c3
MD5 042290f95fa05ac8a8a0ccc6f47acd48
BLAKE2b-256 e2f5851aa2ebe57b8096d6424b7c2d4eea40716e21f8ba66e2a8cc5c6f86d746

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsoniq-0.1.0a5-py3-none-any.whl:

Publisher: deploy.yml on RumbleDB/python-jsoniq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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