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

[Python] Casting Table to new schema ignores nullability of fields

    XMLWordPrintableJSON

Details

    Description

      Similar to ARROW-15478, but not for nested fields but just for casting a full Table (in theory that could be the same code, but currently the Table.cast logic is implemented in cython).

      So currently when casting a Table to a new schema, the nullability of the fields in the schema is ignored (and as a result you get an "invalid" schema indicating a field is non-nullable that actually can have nulls):

      >>> table = pa.table({'a': [None, 1]})
      >>> table
      pyarrow.Table
      a: int64
      ----
      a: [[null,1]]
      
      >>> new_schema = pa.schema([pa.field("a", "int64", nullable=False)])
      >>> table.cast(new_schema)
      pyarrow.Table
      a: int64 not null
      ----
      a: [[null,1]]
      

      Attachments

        Issue Links

          Activity

            People

              kshitij12345 Kshiteej K
              jorisvandenbossche Joris Van den Bossche
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 2h 10m
                  2h 10m