Skip to content

Commit b28552a

Browse files
Preparation of alpha 7
Improvements
2 parents 8cfc3a7 + 90061ff commit b28552a

File tree

6 files changed

+67
-1
lines changed

6 files changed

+67
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,12 @@ Even more queries can be found [here](https://colab.research.google.com/github/R
349349

350350
# Latest updates
351351

352+
## Version 0.2.0 alpha 7
353+
- rumble.lastResult now returns a pyspark/pandas DataFrame or rdd or tuple and no longer the sequence object.
354+
- Enhance schema detection. When the detected static type of the overall query is DataFrame-compatible, it is now automatically possible to obtain the output as a DataFrame without explicitly giving a schema.
355+
- It is now possible to access a table previously registered as a view via a table() function call. This is an alternative to binding variables.
356+
- Enhancements in the JSONiq Update Facility support to update delta files and Hive metastore tables.
357+
352358
## Version 0.2.0 alpha 6
353359
- Fix a bug with the config() call of the builder.
354360
- add withDelta() to configure Delta Lake tables and files, for use with the JSONiq Update Facility.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "jsoniq"
7-
version = "0.2.0a6"
7+
version = "0.2.0a7"
88
description = "Python edition of RumbleDB, a JSONiq engine"
99
requires-python = ">=3.11"
1010
dependencies = [
891 Bytes
Binary file not shown.

tests/test_sample.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def test1(self):
7171
return [$join]
7272
""");
7373

74+
self.assertIn("DataFrame", seq.availableOutputs())
75+
self.assertIn("RDD", seq.availableOutputs())
76+
self.assertIn("Local", seq.availableOutputs())
7477
print(seq.json());
78+
self.assertTrue(json.dumps(seq.json()) == json.dumps(([{'nb': 1, 'state': 'MA', 'sold': 'broiler'}, {'nb': 1, 'state': 'MA', 'sold': 'socks'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'socks'}, {'nb': 3, 'state': 'CA', 'sold': 'toaster'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'shirt'}],)))
7579

7680
seq = rumble.jsoniq("""
7781
for $product in json-lines("http://rumbledb.org/samples/products-small.json", 10)

tests/test_test1.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ def test1(self):
4242
expected = [[{'nb': 1, 'state': 'MA', 'sold': 'broiler'}, {'nb': 1, 'state': 'MA', 'sold': 'socks'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'socks'}, {'nb': 3, 'state': 'CA', 'sold': 'toaster'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'shirt'}]]
4343

4444
self.assertTrue(json.dumps(seq.json()) == json.dumps(expected))
45+
46+
self.assertIn("DataFrame", seq.availableOutputs())
47+
48+
seq.df().show()
49+
50+
self.assertEqual(seq.df().count(), 1)

tests/test_test2.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from jsoniq import RumbleSession
2+
from unittest import TestCase
3+
import json
4+
class TryTesting(TestCase):
5+
def test1(self):
6+
# The syntax to start a session is similar to that of Spark.
7+
# A RumbleSession is a SparkSession that additionally knows about RumbleDB.
8+
# All attributes and methods of SparkSession are also available on RumbleSession.
9+
rumble = RumbleSession.builder.appName("PyRumbleExample").getOrCreate();
10+
# A more complex, standalone query
11+
12+
seq = rumble.jsoniq("""
13+
let $stores :=
14+
[
15+
{ "store number" : 1, "state" : "MA" },
16+
{ "store number" : 2, "state" : "MA" },
17+
{ "store number" : 3, "state" : "CA" },
18+
{ "store number" : 4, "state" : "CA" }
19+
]
20+
let $sales := [
21+
{ "product" : "broiler", "store number" : 1, "quantity" : 20 },
22+
{ "product" : "toaster", "store number" : 2, "quantity" : 100 },
23+
{ "product" : "toaster", "store number" : 2, "quantity" : 50 },
24+
{ "product" : "toaster", "store number" : 3, "quantity" : 50 },
25+
{ "product" : "blender", "store number" : 3, "quantity" : 100 },
26+
{ "product" : "blender", "store number" : 3, "quantity" : 150 },
27+
{ "product" : "socks", "store number" : 1, "quantity" : 500 },
28+
{ "product" : "socks", "store number" : 2, "quantity" : 10 },
29+
{ "product" : "shirt", "store number" : 3, "quantity" : 10 }
30+
]
31+
let $join :=
32+
for $store in $stores[], $sale in $sales[]
33+
where $store."store number" = $sale."store number"
34+
return {
35+
"nb" : $store."store number",
36+
"state" : $store.state,
37+
"sold" : $sale.product
38+
}
39+
return $join
40+
""");
41+
42+
expected = ({'nb': 1, 'state': 'MA', 'sold': 'broiler'}, {'nb': 1, 'state': 'MA', 'sold': 'socks'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'toaster'}, {'nb': 2, 'state': 'MA', 'sold': 'socks'}, {'nb': 3, 'state': 'CA', 'sold': 'toaster'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'blender'}, {'nb': 3, 'state': 'CA', 'sold': 'shirt'})
43+
44+
self.assertTrue(json.dumps(seq.json()) == json.dumps(expected))
45+
46+
self.assertIn("DataFrame", seq.availableOutputs())
47+
48+
seq.df().show()
49+
50+
self.assertEqual(seq.df().count(), 9)

0 commit comments

Comments
 (0)