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

[Python] pa.array() sometimes ignore "safe=False"

Add voteWatch issue
    XMLWordPrintableJSON

Details

    • Bug
    • Status: In Progress
    • Minor
    • Resolution: Unresolved
    • 0.17.0
    • None
    • Python

    Description

      Generally, pa.array(data).cast(sometype, safe=...) is equivalent to
      pa.array(data, sometype, safe=...). Consider the following:

      >>> pa.array([Decimal('12.34')]).cast(pa.int32(), safe=False)                                                                                                               
      <pyarrow.lib.Int32Array object at 0x7efbbd1556e0>
      [
        12
      ]
      >>> pa.array([Decimal('12.34')], pa.int32(), safe=False)                                                                                                                    
      <pyarrow.lib.Int32Array object at 0x7efbbd13dad0>
      [
        12
      ]
      

      However, that is not always the case:

      >>> pa.array([Decimal('1234')]).cast(pa.int8(), safe=False)                                                                                                                 
      <pyarrow.lib.Int8Array object at 0x7efbbd18e4b0>
      [
        -46
      ]
      >>> pa.array([Decimal('1234')], pa.int8(), safe=False)                                                                                                                      
      Traceback (most recent call last):
        ...
      ArrowInvalid: Value 1234 too large to fit in C integer type
      

      I don't think this is very important: first because you can call cast() directly, second because the results are unusable anyway.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              apitrou Antoine Pitrou

              Dates

                Created:
                Updated:

                Time Tracking

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

                  Slack

                    Issue deployment