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

Function test_table_flatten

python/pyarrow/tests/test_table.py:1945–1962  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1943
1944
1945def test_table_flatten():
1946 ty1 = pa.struct([pa.field('x', pa.int16()),
1947 pa.field('y', pa.float32())])
1948 ty2 = pa.struct([pa.field('nest', ty1)])
1949 a = pa.array([(1, 2.5), (3, 4.5)], type=ty1)
1950 b = pa.array([((11, 12.5),), ((13, 14.5),)], type=ty2)
1951 c = pa.array([False, True], type=pa.bool_())
1952
1953 table = pa.Table.from_arrays([a, b, c], names=['a', 'b', 'c'])
1954 t2 = table.flatten()
1955 t2.validate()
1956 expected = pa.Table.from_arrays([
1957 pa.array([1, 3], type=pa.int16()),
1958 pa.array([2.5, 4.5], type=pa.float32()),
1959 pa.array([(11, 12.5), (13, 14.5)], type=ty1),
1960 c],
1961 names=['a.x', 'a.y', 'b.nest', 'c'])
1962 assert t2.equals(expected)
1963
1964
1965def test_table_combine_chunks():

Callers

nothing calls this directly

Calls 4

equalsMethod · 0.80
fieldMethod · 0.45
arrayMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected