|
18 | 18 | from datafusion import SessionContext
|
19 | 19 | from datafusion import substrait as ss
|
20 | 20 |
|
| 21 | +# TODO add user changing interface note to PR that datafusion.substrait.substrait is simplified to datafusion.substrait |
21 | 22 |
|
22 | 23 | # Create a DataFusion context
|
23 | 24 | ctx = SessionContext()
|
24 | 25 |
|
25 | 26 | # Register table with context
|
26 | 27 | ctx.register_csv("aggregate_test_data", "./testing/data/csv/aggregate_test_100.csv")
|
27 | 28 |
|
28 |
| -substrait_plan = ss.substrait.serde.serialize_to_plan( |
29 |
| - "SELECT * FROM aggregate_test_data", ctx |
30 |
| -) |
| 29 | +substrait_plan = ss.serde.serialize_to_plan("SELECT * FROM aggregate_test_data", ctx) |
31 | 30 | # type(substrait_plan) -> <class 'datafusion.substrait.plan'>
|
32 | 31 |
|
33 | 32 | # Encode it to bytes
|
|
38 | 37 | # Alternative serialization approaches
|
39 | 38 | # type(substrait_bytes) -> <class 'bytes'>, at this point the bytes can be distributed to file, network, etc safely
|
40 | 39 | # where they could subsequently be deserialized on the receiving end.
|
41 |
| -substrait_bytes = ss.substrait.serde.serialize_bytes( |
42 |
| - "SELECT * FROM aggregate_test_data", ctx |
43 |
| -) |
| 40 | +substrait_bytes = ss.serde.serialize_bytes("SELECT * FROM aggregate_test_data", ctx) |
44 | 41 |
|
45 | 42 | # Imagine here bytes would be read from network, file, etc ... for example brevity this is omitted and variable is simply reused
|
46 | 43 | # type(substrait_plan) -> <class 'datafusion.substrait.plan'>
|
47 |
| -substrait_plan = ss.substrait.serde.deserialize_bytes(substrait_bytes) |
| 44 | +substrait_plan = ss.serde.deserialize_bytes(substrait_bytes) |
48 | 45 |
|
49 | 46 | # type(df_logical_plan) -> <class 'substrait.LogicalPlan'>
|
50 |
| -df_logical_plan = ss.substrait.consumer.from_substrait_plan(ctx, substrait_plan) |
| 47 | +df_logical_plan = ss.consumer.from_substrait_plan(ctx, substrait_plan) |
51 | 48 |
|
52 | 49 | # Back to Substrait Plan just for demonstration purposes
|
53 | 50 | # type(substrait_plan) -> <class 'datafusion.substrait.plan'>
|
54 |
| -substrait_plan = ss.substrait.producer.to_substrait_plan(df_logical_plan) |
| 51 | +substrait_plan = ss.producer.to_substrait_plan(df_logical_plan) |
0 commit comments