Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes missing child column name in dtype while reading ORC file. #9134

Merged
merged 21 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions python/cudf/cudf/_lib/io/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,6 @@ cdef Column update_column_struct_field_names(
):
cdef vector[string] field_names

if is_struct_dtype(col):
field_names.reserve(len(col.base_children))
for i in range(info.children.size()):
field_names.push_back(info.children[i].name)
col = col._rename_fields(
field_names
)

if col.children:
children = list(col.children)
for i, child in enumerate(children):
Expand All @@ -154,4 +146,13 @@ cdef Column update_column_struct_field_names(
info.children[i]
)
col.set_base_children(tuple(children))

if is_struct_dtype(col):
field_names.reserve(len(col.base_children))
for i in range(info.children.size()):
field_names.push_back(info.children[i].name)
col = col._rename_fields(
field_names
)

return col
Binary file not shown.
20 changes: 17 additions & 3 deletions python/cudf/cudf/tests/test_orc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,21 @@ def test_writer_timestamp_stream_size(datadir, tmpdir):
def test_no_row_group_index_orc_read(datadir, fname):
fpath = datadir / fname

got = pa.orc.ORCFile(fpath).read()
expect = cudf.read_orc(fpath)
expect = pa.orc.ORCFile(fpath).read()
got = cudf.read_orc(fpath)

assert got.equals(expect.to_arrow())
assert expect.equals(got.to_arrow())


def test_names_in_struct_dtype_nesting(datadir):
fname = datadir / "TestOrcFile.NestedStructDataFrame.orc"

expect = pa.orc.ORCFile(fname).read()
got = cudf.read_orc(fname)

# test dataframes
assert expect.equals(got.to_arrow())

edf = cudf.DataFrame(expect.to_pandas())
# test schema
assert edf.dtypes.equals(got.dtypes)