haohuaijin opened a new pull request, #21031:
URL: https://github.com/apache/datafusion/pull/21031

   ## Which issue does this PR close?
   
   - part of #18602.
   
   ## Rationale for this change
   
   When a SQL query contains many filter conditions (e.g., 40+ `AND`/`OR` 
clauses in a `WHERE`), serializing the physical plan to protobuf and 
deserializing it fails with `DecodeError: recursion limit reached`. [This is 
because prost has a default recursion limit of 
100](https://docs.rs/prost/latest/src/prost/lib.rs.html#30), and each 
`BinaryExpr` nesting consumes ~2 levels of protobuf recursion depth, so a chain 
of ~50 AND conditions exceeds the limit.
   
   ## What changes are included in this PR?
   
   Applied the same **linearization** approach that [logical expressions 
already 
use](https://github.com/apache/datafusion/blob/b6b542e87b84f4744096106bea0de755b2e70cc5/datafusion/proto/src/logical_plan/to_proto.rs#L228-L256).
 Instead of encoding a chain of same-operator binary expressions as a deeply 
nested tree, we flatten it into a flat `operands` list:
   
   **Before (nested, O(n) recursion depth):**
   ```
   BinaryExpr(AND) { l: BinaryExpr(AND) { l: BinaryExpr(AND) { l: a, r: b }, r: 
c }, r: d }
   ```
   
   **After (flat, O(1) recursion depth for the chain):**
   ```
   BinaryExpr(AND) { operands: [a, b, c, d] }
   ```
   ## Are these changes tested?
   
   yes, add some test case
   
   ## Are there any user-facing changes?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to