You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-8Lines changed: 38 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,10 +42,16 @@ Any feedback or error reports are very welcome.
42
42
43
43
## Type mapping
44
44
45
-
When passing Python values to JSONiq or getting them from a JSONiq queries, the mapping is as follows:
45
+
Any expression in JSONiq returns a sequence of items. Any variable in JSONiq is bound to a sequence of items.
46
+
Items can be objects, arrays, or atomic values (strings, integers, booleans, nulls, dates, binary, durations, doubles, decimal numbers, etc).
47
+
A sequence of items can be a sequence of just one item, but it can also be empty, or it can be as large as to contain millions, billions or even trillions of items. Obviously, for sequence longer than a billion items, it is a better idea to use a cluster than a laptop.
48
+
A relational table (or more generally a data frame) corresponds to a sequence of object items sharing the same schema. However, sequences of items are more general than tables or data frames and support heterogeneity seamlessly.
49
+
50
+
When passing Python values to JSONiq or getting them from a JSONiq queries, the mapping to and from Python is as follows:
46
51
47
52
| Python | JSONiq |
48
53
|-------|-------|
54
+
|tuple|sequence of items|
49
55
|dict|object|
50
56
|list|array|
51
57
|str|string|
@@ -73,6 +79,7 @@ You can directly copy paste the code below to a Python file and execute it with
73
79
74
80
```
75
81
from jsoniq import RumbleSession
82
+
import pandas as pd
76
83
77
84
# The syntax to start a session is similar to that of Spark.
78
85
# A RumbleSession is a SparkSession that additionally knows about RumbleDB.
@@ -155,16 +162,16 @@ print(seq.json());
155
162
###### Binding JSONiq variables to Python values ###########
@@ -324,6 +347,13 @@ Even more queries can be found [here](https://colab.research.google.com/github/R
324
347
325
348
# Last updates
326
349
350
+
## Version 0.1.0 alpha 13
351
+
- Allow to bind JSONiq variables to pandas dataframes
352
+
- Allow to retrieve the output of a JSONiq query as a pandas dataframe (if the output is available as a dataframe, i.e., availableOutputs() returns a list that contains "DataFrame")
353
+
- Clean up the mapping to strictly map tuples to sequence of items, and lists ot array items. This will avoid confusion between arrays and sequences.
354
+
- As a consequence, json() now returns a tuple, not a list.
355
+
- Calling bind() with a single list will return an informative error. Use bind() with a tuple instead, or call bindOne() to interpret the list as a sequence of one array item.
356
+
327
357
## Version 0.1.0 alpha 12
328
358
- Allow to bind JSONiq variables to Python values (mapping Python lists to sequences of items). This makes it possible to manipulate Python values directly with JSONiq and even without any knowledge of Spark at all.
329
359
- renamed bindDataFrameAsVariable() to bind(), which can be used both with DataFrames and Python lists.
raiseValueError("To avoid confusion, a sequence of items must be provided as a Python tuple, not as a Python list. Lists are mapped to single array items, while tuples are mapped to sequences of items. If you want to interpret the list as a sequence of items (one item for each list member), then you need to change this list to a tuple by wrapping it into a tuple() call. If you want to bind the variable to one array item, then you need to wrap the provided list inside a singleton tuple and try again, or you can also call bindOne() instead.")
0 commit comments