Implement protobuf serialization for Expr::ScalarSubquery(_) | Expr::InSubquery { .. } | Expr::Exists { .. }
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.**
Note depends on:
- [x] https://github.com/apache/arrow-datafusion/issues/4338
In IOx, when a user issued an unsupported subquery, they got a very confusing message about serialization
```
❯ select count(*) from foo where exists (select column1 from foo);
Error during planning: Error encoding expr as protobuf: General error: Proto serialization error: Expr::ScalarSubquery(_) | Expr::InSubquery { .. } | Expr::Exists { .. }#6195
```
This is because the EXISTS predicate could not be sent / serialized. If it could have been, the code in the physical plan would have said "does not support logical exists (SUBQUERY)"
**Describe the solution you'd like**
I would like to implement the protobuf serialization for such subqueries. This would allow the user to see the real error
```
❯ select count(*) from foo where exists (select column1 from foo);
NotImplemented("Physical plan does not support logical expression EXISTS ()")
```
https://github.com/apache/arrow-datafusion/blob/d355f69aae2cc951cfd021e5c0b690861ba0c4ac/datafusion/proto/src/to_proto.rs#L850-L853
However in order to do so we would likely have to serialize entire LogicalPlans -- https://github.com/apache/arrow-datafusion/issues/4338
**Describe alternatives you've considered**
We could put a specific error in IOx for this error but I would prefer to implement the protobuf serialization because it will stay in sync with DataFusions features (e.g. when datafusion does support this kind of query, we won't have to remember to remove the IOx specific check)
**Additional context**
Add any other context or screenshots about the feature request here.
Contributor guide
Research direction
Start at datafusion/proto/src/to_proto.rs#L850-L853 and read the dependency issue #4338 about serializing entire LogicalPlans. Reproduce the EXISTS query from the issue to observe the current serialization failure. Done means subqueries can be protobuf-serialized and the query reports the physical-plan unsupported-expression error instead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100