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

Function test_cast_from_null

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

Source from the content-addressed store, hash-verified

1915
1916
1917def test_cast_from_null():
1918 in_data = [None] * 3
1919 in_type = pa.null()
1920 out_types = [
1921 pa.null(),
1922 pa.uint8(),
1923 pa.float16(),
1924 pa.utf8(),
1925 pa.binary(),
1926 pa.binary(10),
1927 pa.list_(pa.int16()),
1928 pa.list_(pa.int32(), 4),
1929 pa.large_list(pa.uint8()),
1930 pa.decimal128(19, 4),
1931 pa.timestamp('us'),
1932 pa.timestamp('us', tz='UTC'),
1933 pa.timestamp('us', tz='Europe/Paris'),
1934 pa.duration('us'),
1935 pa.month_day_nano_interval(),
1936 pa.struct([pa.field('a', pa.int32()),
1937 pa.field('b', pa.list_(pa.int8())),
1938 pa.field('c', pa.string())]),
1939 pa.dictionary(pa.int32(), pa.string()),
1940 ]
1941 for out_type in out_types:
1942 _check_cast_case((in_data, in_type, in_data, out_type))
1943
1944 out_types = [
1945
1946 pa.union([pa.field('a', pa.binary(10)),
1947 pa.field('b', pa.string())], mode=pa.lib.UnionMode_DENSE),
1948 pa.union([pa.field('a', pa.binary(10)),
1949 pa.field('b', pa.string())], mode=pa.lib.UnionMode_SPARSE),
1950 ]
1951 in_arr = pa.array(in_data, type=pa.null())
1952 for out_type in out_types:
1953 with pytest.raises(NotImplementedError):
1954 in_arr.cast(out_type)
1955
1956
1957def 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