Commit 86e5a38
authored
fix: restore Stage plan during deserialization round-trip (#404)
Closes #402
### Problem
After #345, `parse_stage_proto` unconditionally sets `stage.plan = None`
during deserialization, discarding children that DataFusion's framework
correctly deserialized. This breaks any architecture
where the distributed plan goes through a serialize/deserialize
round-trip before `DistributedExec::prepare_plan()` runs — such as Arrow
Flight SQL's two-phase `GetFlightInfo`/`DoGet` protocol.
### Fix
`children()` on network boundary nodes already encodes plan presence: it
returns `[plan]` when `Some`, `[]` when `None`. DataFusion's
serialization framework preserves this through the round-trip and
passes the deserialized children as `inputs`. The fix infers plan
presence from `inputs` rather than ignoring them:
```rust
plan: inputs.first().cloned(),
```
### Tests
- Updated two existing tests (`test_roundtrip_single_flight`,
`test_roundtrip_single_flight_coalesce`) to pass correct inputs for
stages with `plan: None`
- Added two new tests (`test_roundtrip_single_flight_with_plan`,
`test_roundtrip_single_flight_coalesce_with_plan`) that validate the
round-trip when a stage has `plan: Some(...)`
### Visibility changes
In a Flight SQL architecture, the coordinator server operates in two
distinct phases separated by a network boundary:
1. GetFlightInfo — optimizes the query and serializes the full physical
plan (including DFD's network boundary nodes) into a ticket
2. DoGet — deserializes the plan from the ticket and executes it
This means the server must be able to serialize and deserialize DFD's
plan nodes independently of DFD's internal machinery. To do this, it
needs DistributedCodec in its PhysicalExtensionCodec chain — otherwise
the server has no way to round-trip NetworkShuffleExec,
NetworkCoalesceExec, etc. through the ticket.
Similarly, a Flight SQL server that also acts as a DFD worker needs to
implement the WorkerService gRPC trait. This requires
WorkerServiceServer to register the service with tonic,
FlightAppMetadata to read passthrough headers from requests, and
Worker::impl_execute_task to delegate task execution. The error
conversion functions (datafusion_error_to_tonic_status, etc.) are needed
to translate between DFD's error types and gRPC status codes in the
server's request handlers.
Currently these types are all pub(crate), which forces downstream Flight
SQL integrations to fork the crate just to access them. Making them
public allows DFD to be used as a library in these architectures without
modification.1 parent d862428 commit 86e5a38
3 files changed
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
559 | 568 | | |
560 | 569 | | |
561 | 570 | | |
| |||
581 | 590 | | |
582 | 591 | | |
583 | 592 | | |
584 | | - | |
| 593 | + | |
585 | 594 | | |
586 | 595 | | |
587 | 596 | | |
| |||
686 | 695 | | |
687 | 696 | | |
688 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
689 | 741 | | |
690 | 742 | | |
691 | 743 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments