Skip to main content

Python edition of RumbleDB, a JSONiq engine

Project description

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.0a2.tar.gz (13.2 kB 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.0a2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jsoniq-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 826e96b3ca0d5639232f2dbf5996bb51985a78972b33b5217cb68121fb1b75df
MD5 1afe72029bd81898ad4941045a8c2001
BLAKE2b-256 2d776637f076c196cf0e37dffd3efad8e2524e32648554917762f1b970f60898

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsoniq-0.1.0a2.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.0a2-py3-none-any.whl.

File metadata

  • Download URL: jsoniq-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • 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.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e3fa3f1e479ba4cbbd1ee006db1156236802ef2848e10b9894d748875a5d976
MD5 7267b3834981810a58f339ec5babc1e8
BLAKE2b-256 2bd6d54fa7fa1d9630b74064ff40f8ca16caec82eff8aad75c5f2cfa56af2305

See more details on using hashes here.

Provenance

The following attestation bundles were made for jsoniq-0.1.0a2-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