sunchao opened a new issue, #3620:
URL: https://github.com/apache/arrow-rs/issues/3620

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   <!--
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   -->
   
   Currently for common expressions such as `AND` or `OR`, we don't apply any 
short-circuiting and therefore the same columnar batch need to be fully 
evaluated on every predicate.
   
   For instance, consider an expression:
   ```sql
   a = 'FOO' AND b = 42
   ```
   
   We would evaluate each batch on both predicates, and apply bit-and on the 
result `BooleanArray` from both side. Similarly for `OR`.
   
   This would not be efficient in many cases, nor correct (see 
https://github.com/apache/arrow-datafusion/issues/5093 for a bug report). A 
more efficient approach, is perhaps to only apply the second predicate on the 
**remaining rows** from the evaluation of the first predicate. This could be 
especially effective if the first predicate has low selectivity. 
   
   Note, sometimes it would still be beneficial to evaluate the full batch to 
take advantage of SIMD. For a detailed analysis, please check 
https://dl.acm.org/doi/abs/10.1145/3465998.3466009.
   
   This approach has been adopted by other popular engines such as Velox, 
Databricks Photon, etc.
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   Implement the short-circuiting logic in both `arrow-rs` and 
`arrow-datafusion`. This could introduce a lot of API changes since we may need 
to introduce an extra parameter `SelectivityVector` for related compute kernels 
(e.g., `is_null`). We also need to change `arrow-datafusion`'s 
[`PhysicalExpr::evaluate`](https://github.com/apache/arrow-datafusion/blob/master/datafusion/physical-expr/src/physical_expr.rs#L47)
 to take the `SelectivityVector` into account. Note similar features has been 
done for `CASE WHEN` with the introduction of a separate `evaluate_selection` 
method. See https://github.com/apache/arrow-datafusion/pull/2068 for more 
details.
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   N/A
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   
   N/A


-- 
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: github-unsubscr...@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to