Skip to content

Commit

Permalink
document the usage
Browse files Browse the repository at this point in the history
  • Loading branch information
amol- committed Apr 10, 2024
1 parent cae8153 commit dfe234f
Showing 1 changed file with 79 additions and 1 deletion.
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,84 @@ relations {
}
```

## Load a Substrait Plan from JSON
A substrait plan can be loaded from its JSON representation
using the ``substrait.json.load_json`` and ``substrait.json.parse_json``
functions:

```
>>> import substrait.json
>>> jsontext = """{
... "relations":[
... {
... "root":{
... "input":{
... "read":{
... "baseSchema":{
... "names":[
... "first_name",
... "surname"
... ],
... "struct":{
... "types":[
... {
... "string":{
... "nullability":"NULLABILITY_REQUIRED"
... }
... },
... {
... "string":{
... "nullability":"NULLABILITY_REQUIRED"
... }
... }
... ]
... }
... },
... "namedTable":{
... "names":[
... "people"
... ]
... }
... }
... },
... "names":[
... "first_name"
... ]
... }
... }
... ]
... }"""
>>> substrait.json.parse_json(jsontext)
relations {
root {
input {
read {
base_schema {
names: "first_name"
names: "surname"
struct {
types {
string {
nullability: NULLABILITY_REQUIRED
}
}
types {
string {
nullability: NULLABILITY_REQUIRED
}
}
}
}
named_table {
names: "people"
}
}
}
names: "first_name"
}
}
```

## Produce a Substrait Plan with Ibis
Let's use an existing Substrait producer, [Ibis](https://ibis-project.org),
to provide an example using Python Substrait as the consumer.
Expand Down Expand Up @@ -280,4 +358,4 @@ version {
minor_number: 24
producer: "ibis-substrait"
}
```
```

0 comments on commit dfe234f

Please sign in to comment.