From 224eb13530c7412b3467b613f682b1758aea2c53 Mon Sep 17 00:00:00 2001 From: Nghia Truong Date: Wed, 26 May 2021 14:41:24 -0600 Subject: [PATCH] Add more explanation to the comments --- cpp/src/structs/utilities.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpp/src/structs/utilities.cpp b/cpp/src/structs/utilities.cpp index 79895651c7c..80bea2ab55e 100644 --- a/cpp/src/structs/utilities.cpp +++ b/cpp/src/structs/utilities.cpp @@ -95,10 +95,16 @@ struct flattened_table { { // Even if it is not required to extract the bitmask to a separate column, // we should always do that if the structs column has any null element. + // // In addition, we should check for null by calling to `has_nulls()`, not `nullable()`. // This is because when comparing structs columns, if one column has bitmask while the other // does not (and both columns do not have any null element) then flattening them using // `nullable()` will result in tables with different number of columns. + // + // Notice that, for comparing structs columns when one column has null while the other + // doesn't, `nullability` must be passed in with value `column_nullability::FORCE` to make + // sure the flattening results are tables having the same number of columns. + if (nullability == column_nullability::FORCE || col.has_nulls()) { validity_as_column.push_back(cudf::is_valid(col)); if (col.has_nulls()) {