This release is a pre-release and may not be stable for production use.
RumbleDB for Python
by Abishek Ramdas and Ghislain Fourny
This is the Python edition of RumbleDB, which brings JSONiq to the world of Spark and DataFrames. JSONiq is a language considerably more powerful than SQL as it can process messy, heterogeneous datasets, from kilobytes to Petabytes, with very little coding effort.
The Python edition of RumbleDB is currently only a prototype (alpha) and probably unstable.
High-level information
A RumbleSession is a wrapper around a SparkSession that additionally makes sure the RumbleDB environment is in scope.
JSONiq queries are invoked with rumble.jsoniq() in a way similar to the way Spark SQL queries are invoked with spark.sql().
Any number of Python DataFrames can be attached to JSONiq variables used in the query. It will later also possible to read tables registered in the Hive metastore, similar to spark.sql(). Alternatively, the JSONiq query can also read many files of many different formats from many places (local drive, HTTP, S3, HDFS, ...) directly with simple builtin function calls (see RumbleDB's documentation).
The resulting sequence of items can be retrieved as DataFrame, as an RDD, as a Python list, or with a streaming iteration over the items.
The individual items can be processed using the RumbleDB Item API.
Alternatively, it is possible to directly get an RDD of Python-friendly JSON values, or a Python list of JSON values, or a streaming iteration of JSON values. This is a convenience that makes it unnecessary to use the Item API, especially for a first-time user.
The design goal is that it should be possible to chain DataFrames between JSONiq and Spark SQL queries seamlessly. For example, JSONiq can be used to clean up very messy data and turn it into a clean DataFrame, which can then be processed with Spark SQL, spark.ml, etc.
Any feedback or error reports are very welcome.
Installation
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();
# This gets an RDD of JSON values that can be processed by Python rdd = res.getAsJSONRDD();
print(rdd.count());
for str in rdd.take(10):
print(str);
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsoniq-0.1.0a7.tar.gz.
File metadata
- Download URL: jsoniq-0.1.0a7.tar.gz
- Upload date:
- Size: 25.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
042803d1b04ef7effd324a3fd31e33d2c7067e591336d95bef594da45a2474f0
|
|
| MD5 |
d2901532fc0a85dd5cb452466515279a
|
|
| BLAKE2b-256 |
e1caf95bfdf7e1edddd3f92df774475834250e6df29b76e66557c8f422734221
|
Provenance
The following attestation bundles were made for jsoniq-0.1.0a7.tar.gz:
Publisher:
deploy.yml on RumbleDB/python-jsoniq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsoniq-0.1.0a7.tar.gz -
Subject digest:
042803d1b04ef7effd324a3fd31e33d2c7067e591336d95bef594da45a2474f0 - Sigstore transparency entry: 271726906
- Sigstore integration time:
-
Permalink:
RumbleDB/python-jsoniq@f9f81ef1b94bae889d1466e2ba1756600b68156a -
Branch / Tag:
refs/tags/0.1.0a7 - Owner: https://github.com/RumbleDB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@f9f81ef1b94bae889d1466e2ba1756600b68156a -
Trigger Event:
push
-
Statement type:
File details
Details for the file jsoniq-0.1.0a7-py3-none-any.whl.
File metadata
- Download URL: jsoniq-0.1.0a7-py3-none-any.whl
- Upload date:
- Size: 25.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b916387bdaf8a0e702b89bf2a41d71eed297ceb8d7d5994788d5f7125059bc81
|
|
| MD5 |
af70841020199a1afebf039fbe4aa054
|
|
| BLAKE2b-256 |
72224fbacb5c67f55810a56e4fba3d69f3ce7cc6fd0e4d201fba18482abc0d97
|
Provenance
The following attestation bundles were made for jsoniq-0.1.0a7-py3-none-any.whl:
Publisher:
deploy.yml on RumbleDB/python-jsoniq
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jsoniq-0.1.0a7-py3-none-any.whl -
Subject digest:
b916387bdaf8a0e702b89bf2a41d71eed297ceb8d7d5994788d5f7125059bc81 - Sigstore transparency entry: 271726916
- Sigstore integration time:
-
Permalink:
RumbleDB/python-jsoniq@f9f81ef1b94bae889d1466e2ba1756600b68156a -
Branch / Tag:
refs/tags/0.1.0a7 - Owner: https://github.com/RumbleDB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@f9f81ef1b94bae889d1466e2ba1756600b68156a -
Trigger Event:
push
-
Statement type: