diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index cbe2811afe4..7870366b714 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -189,7 +189,6 @@ add_library( src/ast/expression_parser.cpp src/ast/expressions.cpp src/binaryop/binaryop.cpp - src/binaryop/compiled/binary_ops.cu src/binaryop/compiled/Add.cu src/binaryop/compiled/ATan2.cu src/binaryop/compiled/BitwiseAnd.cu @@ -220,6 +219,7 @@ add_library( src/binaryop/compiled/ShiftRightUnsigned.cu src/binaryop/compiled/Sub.cu src/binaryop/compiled/TrueDiv.cu + src/binaryop/compiled/binary_ops.cu src/binaryop/compiled/util.cpp src/labeling/label_bins.cu src/bitmask/null_mask.cu diff --git a/cpp/include/cudf/detail/structs/utilities.hpp b/cpp/include/cudf/detail/structs/utilities.hpp index 751b7c00e8a..45d4c3b5ae4 100644 --- a/cpp/include/cudf/detail/structs/utilities.hpp +++ b/cpp/include/cudf/detail/structs/utilities.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, NVIDIA CORPORATION. + * Copyright (c) 2020-2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -245,6 +245,20 @@ std::tuple> superimpose_parent table_view const& table, rmm::cuda_stream_view stream = rmm::cuda_stream_default, rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + +/** + * @brief Checks if a column or any of its children is a struct column with structs that are null. + * + * This function searches for structs that are null -- differentiating between structs that are null + * and structs containing null values. Null structs add a column to the result of the flatten column + * utility and necessitates column_nullability::FORCE when flattening the column for comparison + * operations. + * + * @param col Column to check for null structs + * @return A boolean indicating if the column is or contains a struct column that contains a null + * struct. + */ +bool contains_null_structs(column_view const& col); } // namespace detail } // namespace structs } // namespace cudf diff --git a/cpp/include/cudf/table/row_operators.cuh b/cpp/include/cudf/table/row_operators.cuh index 4eca03a800c..4d503cd53b8 100644 --- a/cpp/include/cudf/table/row_operators.cuh +++ b/cpp/include/cudf/table/row_operators.cuh @@ -74,7 +74,7 @@ __device__ weak_ordering compare_elements(Element lhs, Element rhs) * @brief A specialization for floating-point `Element` type relational comparison * to derive the order of the elements with respect to `lhs`. * - * This Specialization handles `nan` in the following order: + * This specialization handles `nan` in the following order: * `[-Inf, -ve, 0, -0, +ve, +Inf, NaN, NaN, null] (for null_order::AFTER)` * `[null, -Inf, -ve, 0, -0, +ve, +Inf, NaN, NaN] (for null_order::BEFORE)` * diff --git a/cpp/include/cudf/utilities/traits.hpp b/cpp/include/cudf/utilities/traits.hpp index ed24517f55b..d8fa7bff0b8 100644 --- a/cpp/include/cudf/utilities/traits.hpp +++ b/cpp/include/cudf/utilities/traits.hpp @@ -699,6 +699,37 @@ constexpr inline bool is_nested(data_type type) return cudf::type_dispatcher(type, is_nested_impl{}); } +/** + * @brief Indicates whether `T` is a struct type. + * + * @param T The type to verify + * @return A boolean indicating if T is a struct type + */ +template +constexpr inline bool is_struct() +{ + return std::is_same_v; +} + +struct is_struct_impl { + template + constexpr bool operator()() + { + return is_struct(); + } +}; + +/** + * @brief Indicates whether `type` is a struct type. + * + * @param type The `data_type` to verify + * @return A boolean indicating if `type` is a struct type + */ +constexpr inline bool is_struct(data_type type) +{ + return cudf::type_dispatcher(type, is_struct_impl{}); +} + template struct is_bit_castable_to_impl { template ()>* = nullptr> diff --git a/cpp/src/structs/utilities.cpp b/cpp/src/structs/utilities.cpp index a2c173cae5f..5baab0f09a2 100644 --- a/cpp/src/structs/utilities.cpp +++ b/cpp/src/structs/utilities.cpp @@ -441,6 +441,12 @@ std::tuple> superimpose_parent return {table_view{superimposed_columns}, std::move(superimposed_nullmasks)}; } +bool contains_null_structs(column_view const& col) +{ + return (is_struct(col) && col.has_nulls()) || + std::any_of(col.child_begin(), col.child_end(), contains_null_structs); +} + } // namespace detail } // namespace structs } // namespace cudf