MCPcopy Create free account
hub / github.com/apache/arrow / test_cast_from_null

Function test_cast_from_null

python/pyarrow/tests/test_array.py:2032–2069  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2030
2031
2032def test_cast_from_null():
2033 in_data = [None] * 3
2034 in_type = pa.null()
2035 out_types = [
2036 pa.null(),
2037 pa.uint8(),
2038 pa.float16(),
2039 pa.utf8(),
2040 pa.binary(),
2041 pa.binary(10),
2042 pa.list_(pa.int16()),
2043 pa.list_(pa.int32(), 4),
2044 pa.large_list(pa.uint8()),
2045 pa.decimal128(19, 4),
2046 pa.timestamp('us'),
2047 pa.timestamp('us', tz='UTC'),
2048 pa.timestamp('us', tz='Europe/Paris'),
2049 pa.duration('us'),
2050 pa.month_day_nano_interval(),
2051 pa.struct([pa.field('a', pa.int32()),
2052 pa.field('b', pa.list_(pa.int8())),
2053 pa.field('c', pa.string())]),
2054 pa.dictionary(pa.int32(), pa.string()),
2055 ]
2056 for out_type in out_types:
2057 _check_cast_case((in_data, in_type, in_data, out_type))
2058
2059 out_types = [
2060
2061 pa.union([pa.field('a', pa.binary(10)),
2062 pa.field('b', pa.string())], mode=pa.lib.UnionMode_DENSE),
2063 pa.union([pa.field('a', pa.binary(10)),
2064 pa.field('b', pa.string())], mode=pa.lib.UnionMode_SPARSE),
2065 ]
2066 in_arr = pa.array(in_data, type=pa.null())
2067 for out_type in out_types:
2068 with pytest.raises(NotImplementedError):
2069 in_arr.cast(out_type)
2070
2071
2072def test_cast_string_to_number_roundtrip():

Callers

nothing calls this directly

Calls 6

_check_cast_caseFunction · 0.85
fieldMethod · 0.45
stringMethod · 0.45
dictionaryMethod · 0.45
arrayMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected