You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jayzhan211 (via GitHub)" <gi...@apache.org> on 2024/02/18 12:47:55 UTC

[I] Comparison for nested type [arrow-rs]

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

   **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*)
   -->
   
   I want to be able to compare ListArray. The comparison order is left to right and if the prefix is the same then it is considered.
   lesser.
   
   For example, 
   * List(1,2,3) < List(1,2,3,4)
   * List(List(1,2,3), List(10)) < List(List(1,2,4), List(1))
   * List(List(1,2,3), List(1)) > List(List(1,2,2), List(2))
   
   > The behavior takes Duckdb's array sort as a reference.
   
   **Describe the solution you'd like**
   <!--
   A clear and concise description of what you want to happen.
   -->
   
   Support nested types in `compare_op`, currently failed on this line.
   ```rust
       if l_t != r_t || l_t.is_nested() {
           return Err(ArrowError::InvalidArgumentError(format!(
               "Invalid comparison operation: {l_t} {op} {r_t}"
           )));
       }
   ```
   
   **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.
   -->
   
   We can support most of the ops in the future, `lt` and `eq` are two important functions that should work first.


-- 
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-unsubscribe@arrow.apache.org.apache.org

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


Re: [I] Comparison for nested type [arrow-rs]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on issue #5407:
URL: https://github.com/apache/arrow-rs/issues/5407#issuecomment-2184954842

   > I'm not sure we want to support this within these kernels, in particular the null behaviour is not well-defined. I added support to the comparator for this, which will allow systems like DataFusion to define an ordering for nulls based on a config setting, as Spark and Postgres use different ordering.
   > 
   > There is an example of this here - https://docs.rs/arrow-ord/latest/arrow_ord/ord/fn.make_comparator.html#postgres-compatible-nested-comparison
   > 
   > This will also make it more obvious that the nested comparison is not vectorised
   > 
   > Edit: Filed #5942 to make this more discoverable
   
   Are you suggesting that if datafusion requires nested comparison, we could implement them in datafusion with `make_comparator` like what I had done? Arrow-rs only need support the `make_comparator` kernel for nested type?
   
   https://github.com/apache/datafusion/blob/d32747d09add5e1c670aa32fbe3294ecee15e3b7/datafusion/physical-expr/src/expressions/datum.rs#L28-L58
   
   This is the code that utilize `compare_op`, and nested type is missing
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [I] Comparison for nested type [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5407:
URL: https://github.com/apache/arrow-rs/issues/5407#issuecomment-2184915993

   I'm not sure we want to support this within these kernels, in particular the null behaviour is not well-defined. I added support to the comparator for this, which will allow systems like DataFusion to define an ordering for nulls based on a config setting, as Spark and Postgres use different ordering.
   
   This will also make it more obvious that the nested comparison is not vectorised


-- 
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-unsubscribe@arrow.apache.org

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


Re: [I] Comparison for nested type [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #5407:
URL: https://github.com/apache/arrow-rs/issues/5407#issuecomment-2184969909

   Yes, DataFusion should decide what null semantics it wants / make this configurable, and implement it using make_comparator if appropriate


-- 
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-unsubscribe@arrow.apache.org

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


Re: [I] Comparison for nested type [arrow-rs]

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #5407: Comparison for nested type
URL: https://github.com/apache/arrow-rs/issues/5407


-- 
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-unsubscribe@arrow.apache.org

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