| 38 | } |
| 39 | |
| 40 | void CheckFetch(FetchNodeOptions options) { |
| 41 | constexpr random::SeedType kSeed = 42; |
| 42 | constexpr int kJitterMod = 4; |
| 43 | RegisterTestNodes(); |
| 44 | std::shared_ptr<Table> input = TestTable(); |
| 45 | Declaration plan = |
| 46 | Declaration::Sequence({{"table_source", TableSourceNodeOptions(input)}, |
| 47 | {"jitter", JitterNodeOptions(kSeed, kJitterMod)}, |
| 48 | {"fetch", options}}); |
| 49 | for (bool use_threads : {false, true}) { |
| 50 | QueryOptions query_options; |
| 51 | query_options.use_threads = use_threads; |
| 52 | ASSERT_OK_AND_ASSIGN(std::shared_ptr<Table> actual, |
| 53 | DeclarationToTable(plan, query_options)); |
| 54 | |
| 55 | if (options.offset >= input->num_rows() || options.count == 0) { |
| 56 | // In these cases, Table::Slice would fail or give us a table with 1 chunk while |
| 57 | // the fetch node gives us a table with 0 chunks |
| 58 | ASSERT_EQ(0, actual->num_rows()); |
| 59 | } else { |
| 60 | std::shared_ptr<Table> expected = input->Slice(options.offset, options.count); |
| 61 | AssertTablesEqual(*expected, *actual); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | void CheckFetchInvalid(FetchNodeOptions options, const std::string& message) { |
| 67 | std::shared_ptr<Table> input = TestTable(); |
no test coverage detected