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

Weston Pace commented on ARROW-18334:
-------------------------------------

I had an offline discussion with [~bkietz] on this issue:

 * Canonicalize will only reorder types if it thinks the functions is 
commutative
 * There is a small list of functions which are considered commutative (and 
add_checked is one of them)
 * So we shouldn't need to re-bind

One way to solve this problem is to create a custom output resolver for the 
add(duration, timestamp) kernels which grabs the first timestamp type and uses 
it as the output.

> Expression::Canonicalize does not unbind the expression from a kernel
> ---------------------------------------------------------------------
>
>                 Key: ARROW-18334
>                 URL: https://issues.apache.org/jira/browse/ARROW-18334
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>            Reporter: Weston Pace
>            Priority: Major
>
> In general, we get away with this, since most kernels are of the shape 
> {{FOO(T, T)}}.  However, when the input types differ, this can be a problem.
> Concretely, we have kernels:
> {noformat}
> add_checked<Timestamp,Duration>() -> types[0]
> add_checked<Duration,Timestamp>() -> types[1]
> {noformat}
> A call is made with expression {{field_ref("x") + duration_literal}}.  This 
> call is bound to {{add_checked<Timestamp, Duration>}}.  However, the 
> expression is then simplified to {{duration_literal + field_ref("x")}}.  
> Oddly enough, the math in this case is correct, since it is just addition, 
> but the output type is not.  It assigns an output type of duration instead of 
> timestamp.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to