Uploaded image for project: 'Python Integrations'
  1. Python Integrations
  2. INTPYTHON-167

Int64 converts boolean and floats to ints but Int32 does not

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Int64 converts BSON boolean and floats to ints but Int32 does not. This is unexpected:

      self = <test.test_arrow.TestArrowExplicitApi testMethod=test_int32_mixed_types>
      
          def test_int32_mixed_types(self):
              docs = [
                  {'a': 1},
                  {'a': 2.9},  # float should be truncated.
                  {'a': True},  # True should be 1.
                  {'a': False},  # False should be 0.
                  {'a': None},  # Should be null/missing.
              ]
              self.coll.delete_many({})
              self.coll.insert_many(docs)
              table = find_arrow_all(self.coll, {}, projection={'_id': 0}, schema=Schema({"a": int32()}))
              expected = Table.from_pylist([
                  {'a': 1},
                  {'a': 2},
                  {'a': 1},
                  {'a': 0},
                  {'a': None},
              ], schema=ArrowSchema([field('a', int32())]))
      >       self.assertEqual(table, expected)
      E       AssertionError: pyarrow.Table
      E       a: int32
      E       ----
      E       a: [[1,null,null,null,null]] != pyarrow.Table
      E       a: int32
      E       ----
      E       a: [[1,2,1,0,null]]
      
      test/test_arrow.py:611: AssertionError
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: