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

[Python] Allow scalars when creating expression from compute kernels

    XMLWordPrintableJSON

Details

    Description

      We can create an expression (eg for a projection) using the compute kernels and passing expressions as arguments. But currently, all other arguments need to be expressions:

      >>> pc.add(pc.field("a"), pc.field("b"))    # this works
      <pyarrow.compute.Expression add(a, b)>
      >>> pc.add(pc.field("a"), 1)   # this fails when passing scalar (same for pa.scalar(1))
      ...
      TypeError: only other expressions allowed as arguments
      

      You can still pass a scalar expression (pc.scalar(1), note pc. not pa.), but I think for scalars it would be a nice usability improvement if it's not needed to manually convert your python or pyarrow scalar to a scalar expression.

      Attachments

        Issue Links

          Activity

            People

              milesgranger Miles Granger
              jorisvandenbossche Joris Van den Bossche
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 1h 10m
                  1h 10m