You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/10 08:52:57 UTC

[GitHub] [arrow-datafusion] HaoYang670 opened a new issue, #4165: The functions in `type_coercion` should return `Result`, not `Option`

HaoYang670 opened a new issue, #4165:
URL: https://github.com/apache/arrow-datafusion/issues/4165

   **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, in the `type_coercion` mod, we have some pub functions returning `Result`, such as 
   ```rust
   pub fn coerce_types(
       lhs_type: &DataType,
       op: &Operator,
       rhs_type: &DataType,
   ) -> Result<DataType> {
   ```
   , and others returning `Option`:
   ```rust
   pub fn comparison_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
   ```
   
   We should let all of them to return `Result` so that we can find the error as early as possible. Currently, we do the conversion from `None` to `Error` in the downstream code:
   ```rust
                   let case_when_coerce_type =
                       get_coerce_type_for_case_when(&then_types, &else_type);
                   match case_when_coerce_type {
                       None => Err(DataFusionError::Internal(format!(
                           "Failed to coerce then ({:?}) and else ({:?}) to common types in CASE WHEN expression",
                           then_types, else_type
                       ))),
   ```
   , which should be avoided.
   
   **Describe the solution you'd like**
   A clear and concise description of what you want to happen.
   
   **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: github-unsubscribe@arrow.apache.org.apache.org

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