Skip to content

Commit c9fb2a6

Browse files
authored
feat: drop JSON functions and dependency on substrait-cpp (#100)
Closes #99 Closes #98 BREAKING CHANGE: drop explicit support for JSON api
1 parent aa48c31 commit c9fb2a6

File tree

7 files changed

+7
-111
lines changed

7 files changed

+7
-111
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "third_party/substrait"]
22
path = third_party/substrait
33
url = https://github.com/substrait-io/substrait
4-
[submodule "third_party/substrait-cpp"]
5-
path = third_party/substrait-cpp
6-
url = https://github.com/substrait-io/substrait-cpp

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ relations {
136136
```
137137

138138
## Load a Substrait Plan from JSON
139-
A substrait plan can be loaded from its JSON representation
140-
using the ``substrait.json.load_json`` and ``substrait.json.parse_json``
139+
A substrait plan can be loaded [from the JSON representation
140+
of the protobuf message](https://protobuf.dev/programming-guides/json/) using the [`protobuf` python library](https://pypi.org/project/protobuf/):
141141
functions:
142142

143143
```
144-
>>> import substrait.json
144+
>>> from substrait.proto import Plan
145+
>>> from google.protobuf import json_format
145146
>>> jsontext = """{
146147
... "relations":[
147148
... {
@@ -182,7 +183,7 @@ functions:
182183
... }
183184
... ]
184185
... }"""
185-
>>> substrait.json.parse_json(jsontext)
186+
>>> json_format.Parse(text=jsontext, mesage=Plan())
186187
relations {
187188
root {
188189
input {

src/substrait/json.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/sql/test_sql_to_substrait.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from substrait.sql.sql_to_substrait import convert
22
import pyarrow
3-
import substrait.json
3+
from google.protobuf import json_format
44
import tempfile
55
import pyarrow.substrait as pa_substrait
66
import pytest
@@ -91,7 +91,7 @@ def duckdb_schema_resolver(name: str):
9191
conn.install_extension("substrait", repository="community")
9292
conn.load_extension("substrait")
9393

94-
plan_json = substrait.json.dump_json(plan)
94+
plan_json = json_format.MessageToJson(plan)
9595
sql = f"CALL from_substrait_json('{plan_json}')"
9696

9797
substrait_out = conn.sql(sql)

tests/test_json.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

third_party/substrait-cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

update_cpp.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)