From c0f7ec098cb884edade344d4f84b38760775d796 Mon Sep 17 00:00:00 2001 From: Yan Feng Date: Fri, 6 Dec 2024 11:40:16 +0800 Subject: [PATCH] Fix bug in depth calculation for list of struct columns Signed-off-by: Yan Feng --- src/main/cpp/src/xxhash64.cu | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/src/xxhash64.cu b/src/main/cpp/src/xxhash64.cu index 81aeb3d33..266bea95b 100644 --- a/src/main/cpp/src/xxhash64.cu +++ b/src/main/cpp/src/xxhash64.cu @@ -515,8 +515,13 @@ void check_nested_depth(cudf::table_view const& input) column_checker_fn_t get_nested_depth = [&](cudf::column_view const& col) { if (col.type().id() == cudf::type_id::LIST) { - // list column will be replaced by its most inner non-list child - return get_nested_depth(cudf::lists_column_view(col).child()); + auto const& child_col = cudf::lists_column_view(col).child(); + // When encountering a List of Struct column, we need to account for an extra depth, + // as both the struct column and its elements will be pushed into the stack. + if (child_col.type().id() == cudf::type_id::STRUCT) { + return 1 + get_nested_depth(child_col); + } + return get_nested_depth(child_col); } else if (col.type().id() == cudf::type_id::STRUCT) { int max_child_depth = 0; for (auto child = col.child_begin(); child != col.child_end(); ++child) {