forked from ibis-project/ibis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(datafusion): use pyarrow for type conversion (ibis-project#9299)
- Loading branch information
Showing
4 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters