diff --git a/cpp/src/bitmask/null_mask.cu b/cpp/src/bitmask/null_mask.cu index 8cdcefe9796..78188b26473 100644 --- a/cpp/src/bitmask/null_mask.cu +++ b/cpp/src/bitmask/null_mask.cu @@ -135,7 +135,8 @@ void set_null_mask(bitmask_type *bitmask, { CUDF_FUNC_RANGE(); CUDF_EXPECTS(begin_bit >= 0, "Invalid range."); - CUDF_EXPECTS(begin_bit < end_bit, "Invalid bit range."); + CUDF_EXPECTS(begin_bit <= end_bit, "Invalid bit range."); + if (begin_bit == end_bit) return; if (bitmask != nullptr) { auto number_of_mask_words = num_bitmask_words(end_bit) - begin_bit / detail::size_in_bits(); diff --git a/cpp/tests/bitmask/set_nullmask_tests.cu b/cpp/tests/bitmask/set_nullmask_tests.cu index d51336a315f..ae4896827fd 100644 --- a/cpp/tests/bitmask/set_nullmask_tests.cu +++ b/cpp/tests/bitmask/set_nullmask_tests.cu @@ -105,8 +105,7 @@ TEST_F(SetBitmaskTest, error_range) std::vector begin_end_fail{ {-1, size}, // begin>=0 {-2, -1}, // begin>=0 - {8, 8}, // begin begin_end_pass{ {0, size}, // begin>=0 {0, 1}, // begin>=0 - {8, 9}, // beginview()); } +TYPED_TEST(ScanTest, LeadingNulls) +{ + auto const v = cudf::test::make_type_param_vector({100, 200, 300}); + auto const b = std::vector{0, 1, 1}; + cudf::test::fixed_width_column_wrapper const col_in(v.begin(), v.end(), b.begin()); + std::unique_ptr col_out; + + // expected outputs + std::vector out_v(v.size()); + std::vector out_b(v.size(), 0); + + // skipna=false + CUDF_EXPECT_NO_THROW( + col_out = + cudf::scan(col_in, cudf::make_sum_aggregation(), scan_type::INCLUSIVE, null_policy::INCLUDE)); + cudf::test::fixed_width_column_wrapper expected_col_out( + out_v.begin(), out_v.end(), out_b.begin()); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(expected_col_out, col_out->view()); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected_col_out, col_out->view()); +} + template struct FixedPointTestBothReps : public cudf::test::BaseFixture { };