[ 
https://issues.apache.org/jira/browse/ARROW-14457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433765#comment-17433765
 ] 

Neal Richardson commented on ARROW-14457:
-----------------------------------------

{{Array$create(c(1, 2)) * Array$create(3)}} should error; you probably think it 
should work (by recycling) because R treats length-1 vectors as scalars because 
it has no proper scalar type. {{Array$create(c(1, 2)) * Scalar$create(3)}} does 
recycle (and is what you get when you do {{Array$create(c(1, 2)) * 3}}). 

{{Array$create(c(1,2)) * c(3, 4)}} could be made to work, and in fact there's a 
TODO about it here: 
https://github.com/apache/arrow/blob/master/r/R/arrow-datum.R#L127

> [R] Support multiplying Arrays by R vectors and scalar value recycling
> ----------------------------------------------------------------------
>
>                 Key: ARROW-14457
>                 URL: https://issues.apache.org/jira/browse/ARROW-14457
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Nicola Crane
>            Priority: Major
>
> Scalar value recycling doesn't work on Arrays: 
> {code:r}
> > Array$create(c(1, 2)) * 3
> Array
> <double>
> [
>   3,
>   6
> ]
> > Array$create(c(1, 2)) * Array$create(c(3))
>  Error: Invalid: Array arguments must all be the same length
> /home/nic2/arrow/cpp/src/arrow/compute/exec.cc:569  
> ExecBatchIterator::Make(args, exec_context()->exec_chunksize())
> /home/nic2/arrow/cpp/src/arrow/compute/exec.cc:705  
> this->SetupArgIteration(args)
> /home/nic2/arrow/cpp/src/arrow/compute/exec.cc:630  PrepareExecute(args)
> /home/nic2/arrow/cpp/src/arrow/compute/function.cc:239  
> executor->Execute(implicitly_cast_args, &listener) 
> {code}
> Neither does multiplying by vectors (as they are converted to Scalar lists)
> {code:r}
> > Array$create(c(1,2)) * c(3,4)
>  Error: NotImplemented: Function multiply_checked has no kernel matching 
> input types (array[double], scalar[list<item: double>])
> /home/nic2/arrow/cpp/src/arrow/compute/function.cc:215  DispatchBest(&inputs) 
> > Array$create(c(1, 2)) * Array$create(c(3, 4))
> Array
> <double>
> [
>   3,
>   8
> ]
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to