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/04/18 07:30:30 UTC

[GitHub] [arrow-datafusion] clojurians-org opened a new issue, #2260: create_udf 0 parameter error

clojurians-org opened a new issue, #2260:
URL: https://github.com/apache/arrow-datafusion/issues/2260

   **Describe the bug**
   ```
   index out of bounds: the len is 0 but the index is 0
   ```
   
   **To Reproduce**
   ``` rust
               context.register_udf(create_udf(
                   "database", vec![], Arc::new(DataType::Utf8), Volatility::Volatile,
                   Arc::new(move |args: &[ColumnarValue]| {
                       let len: usize = match &args[0] {
                           ColumnarValue::Array(array) => array.len(),
                           _ => {
                               return Err(DataFusionError::Internal(
                                   "Expect random function to take no param".to_string(),
                               ))
                           }
                       };
                       let values = std::iter::repeat_with(|| "default").take(len) ;
                       let array = StringArray::from_iter_values(values) ;
                       Ok(ColumnarValue::Array(Arc::new(array)))
                   })
               )) ;
   ```
   
   **Expected behavior**
   
   
   **Additional context**
   ```
   arrow = "9.0"
   datafusion = "7.0"
   ```
   


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


[GitHub] [arrow-datafusion] yukkit commented on issue #2260: create_udf 0 parameter error

Posted by "yukkit (via GitHub)" <gi...@apache.org>.
yukkit commented on issue #2260:
URL: https://github.com/apache/arrow-datafusion/issues/2260#issuecomment-1527280989

   The reason is  ```let len: usize = match &args[0] {``` . 
   If your udf takes no arguments, you can return `ColumnarValue::Scalar` instead of `ColumnarValue::Array`.
   
   If there are no other problems, I think this issue can be closed.


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