Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-18334

[C++] add function for timestamp/duration is not commutative

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 11.0.0
    • C++

    Description

      The expression simplification currently has a small set of functions which it knows are commutative (IsBinaryAssociativeCommutative). "add" (and "add_checked" are in this list. This should be ok for add(timestamp,duration) since this boils down to add(int64,int64) which is commutative. However, the way the kernels are currently implemented, we are getting the incorrect output type.

      Concretely, we have kernels:

      add_checked<Timestamp,Duration>() -> types[0]
      add_checked<Duration,Timestamp>() -> types[1]
      

      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.

      Attachments

        Issue Links

          Activity

            People

              bkietz Ben Kietzman
              westonpace Weston Pace
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h
                  5h