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

   **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 `build_compare` can be used to construct a `DynComparator` that 
can be used to establish an ordering between two different array indices. It is 
up to the caller to inspect the null masks, and apply ordering as appropriate. 
This works well for arrays non-nested arrays, but runs into issues when arrays 
have children. 
   
   The introduction of logical nullability worked around this limitation for 
DictionaryArray and RunArray, but it is unclear how best to handle types such 
as StructArray and ListArray. 
   
   Part of the challenge is there isn't one way users may wish to handle nulls:
   
   * When sorting nulls are ordered based on the `SortOptions::nulls_first` 
parameter
   * When used in a comparison operator, the behaviour of nulls depends on the 
operator
   
   Also correctly using `DynComparator` requires understanding the distinction 
between logical and physical nullability, see #4691, which is confusing (#4840)
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   In order to support arbitrarily nested ListArray in comparison kernels, we 
need a mechanism similar to DynComparator but which is able to handle nulls.
   
   I would like something similar to the below
   
   ```
   pub enum Compare {
       LeftNull,
       RightNull,
       BothNull,
       Less,
       Equal,
       Greater,
   }
   
   impl Compare {
       pub fn ordering(&self, nulls_first: bool) -> Ordering {
           ...
       }
   
       #[inline]
       pub fn is_null(&self) -> bool {
           matches!(self, Self::LeftNull | Self::RightNull | Self::BothNull)
       }
   }
   
   pub type Comparator = Box<dyn Fn(usize, usize) -> Compare + Send + Sync>;
   
   pub fn build_comparator(left: &dyn Array, right: &dyn Array) -> 
Result<Comparator> {
       ...
   }
   ```
   
   We could then deprecate and eventually remove `build_compare` and 
`DynComparator`.
   
   **Describe alternatives you've considered**
   <!--
   A clear and concise description of any alternative solutions or features 
you've considered.
   -->
   
   **Additional context**
   <!--
   Add any other context or screenshots about the feature request here.
   -->
   


-- 
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]

Reply via email to