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.0a4.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.0a4-py3-none-any.whl (25.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jsoniq-0.1.0a4.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.0a4.tar.gz
Algorithm Hash digest
SHA256 9de026f665ce757850976b1bde76ad15564636e86017284426d2b084d2458d4b
MD5 a0c8f60cf9dcd5a97bccea19c016ecdf
BLAKE2b-256 cbd20a03f4a1ffc48b6067de15f523d502e1a039109aec42550bff23028d37b8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: jsoniq-0.1.0a4-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.0a4-py3-none-any.whl
Algorithm Hash digest
SHA256 7631641783bf9bc0fc7c76b15ea63095dbf839c873cde50259d7fd70baf6a426
MD5 73ff23e96602aca81d929560b9b75145
BLAKE2b-256 57cc3cf851d62a3e70265724f0d84c8f9964943188e8ac359003b0e5ab86b0a0

See more details on using hashes here.

Provenance

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