Skip to content

Commit

Permalink
test(datafusion-datatypes): test recursive conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jun 4, 2024
1 parent 03ad1e3 commit c82a6b6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ibis/backends/datafusion/tests/test_datatypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

import hypothesis as h

import ibis.tests.strategies as its
from ibis.backends.datafusion import as_nullable


def is_nullable(dtype):
if dtype.is_struct():
return all(map(is_nullable, dtype.values()))
elif dtype.is_array():
return is_nullable(dtype.value_type)
elif dtype.is_map():
return is_nullable(dtype.key_type) and is_nullable(dtype.value_type)
else:
return dtype.nullable is True


@h.given(its.all_dtypes())
def test_as_nullable(dtype):
nullable_dtype = as_nullable(dtype)
assert nullable_dtype.nullable is True
assert is_nullable(nullable_dtype)

0 comments on commit c82a6b6

Please sign in to comment.