Specialized case for GH-40997
| 47 | |
| 48 | // Specialized case for GH-40997 |
| 49 | TEST(Grouper, ResortedColumnsWithLargeNullRows) { |
| 50 | const uint64_t num_rows = 1024; |
| 51 | |
| 52 | // construct random array with plenty of null values |
| 53 | const int32_t kSeed = 42; |
| 54 | const int32_t min = 0; |
| 55 | const int32_t max = 100; |
| 56 | const double null_probability = 0.3; |
| 57 | const double true_probability = 0.5; |
| 58 | auto rng = random::RandomArrayGenerator(kSeed); |
| 59 | auto b_arr = rng.Boolean(num_rows, true_probability, null_probability); |
| 60 | auto i32_arr = rng.Int32(num_rows, min, max, null_probability); |
| 61 | auto i64_arr = rng.Int64(num_rows, min, max * 10, null_probability); |
| 62 | |
| 63 | // construct batches with columns which will be resorted in the grouper make |
| 64 | std::vector<ExecBatch> exec_batches = {ExecBatch({i64_arr, i32_arr, b_arr}, num_rows), |
| 65 | ExecBatch({i32_arr, i64_arr, b_arr}, num_rows), |
| 66 | ExecBatch({i64_arr, b_arr, i32_arr}, num_rows), |
| 67 | ExecBatch({i32_arr, b_arr, i64_arr}, num_rows), |
| 68 | ExecBatch({b_arr, i32_arr, i64_arr}, num_rows), |
| 69 | ExecBatch({b_arr, i64_arr, i32_arr}, num_rows)}; |
| 70 | |
| 71 | const int num_batches = static_cast<int>(exec_batches.size()); |
| 72 | std::vector<uint32_t> group_num_vec; |
| 73 | group_num_vec.reserve(num_batches); |
| 74 | |
| 75 | for (const auto& exec_batch : exec_batches) { |
| 76 | ExecSpan span(exec_batch); |
| 77 | ASSERT_OK_AND_ASSIGN(auto grouper, Grouper::Make(span.GetTypes())); |
| 78 | ASSERT_OK_AND_ASSIGN(Datum group_ids, grouper->Consume(span)); |
| 79 | group_num_vec.emplace_back(grouper->num_groups()); |
| 80 | } |
| 81 | |
| 82 | for (int i = 1; i < num_batches; i++) { |
| 83 | ASSERT_EQ(group_num_vec[i - 1], group_num_vec[i]); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | // Reproduction of GH-43124: Provoke var length buffer size if a grouper produces zero |
| 88 | // groups. |
no test coverage detected