| 37 | constexpr int kRowsPerBatch = 64; |
| 38 | |
| 39 | TEST(PivotLongerNode, Basic) { |
| 40 | std::shared_ptr<Table> input = |
| 41 | gen::Gen({gen::Step(), gen::Step(), gen::Step(), gen::Step()}) |
| 42 | ->FailOnError() |
| 43 | ->Table(kRowsPerBatch, kNumBatches); |
| 44 | |
| 45 | PivotLongerNodeOptions options; |
| 46 | options.feature_field_names = {"feature1", "feature2"}; |
| 47 | options.measurement_field_names = {"meas1", "meas2"}; |
| 48 | options.row_templates = {{{"a", "x"}, {{1}, {3}}}, {{"b", "y"}, {{2}, std::nullopt}}}; |
| 49 | |
| 50 | Declaration plan = Declaration::Sequence({ |
| 51 | {"table_source", TableSourceNodeOptions(std::move(input))}, |
| 52 | {"pivot_longer", options}, |
| 53 | }); |
| 54 | |
| 55 | ASSERT_OK_AND_ASSIGN(std::shared_ptr<Table> output, |
| 56 | DeclarationToTable(std::move(plan))); |
| 57 | |
| 58 | std::shared_ptr<Schema> expected_out_schema = schema({ |
| 59 | field("f0", uint32()), |
| 60 | field("f1", uint32()), |
| 61 | field("f2", uint32()), |
| 62 | field("f3", uint32()), |
| 63 | field("feature1", utf8()), |
| 64 | field("feature2", utf8()), |
| 65 | field("meas1", uint32()), |
| 66 | field("meas2", uint32()), |
| 67 | }); |
| 68 | |
| 69 | ASSERT_EQ(output->num_rows(), kNumBatches * kRowsPerBatch * 2); |
| 70 | AssertSchemaEqual(expected_out_schema, output->schema()); |
| 71 | } |
| 72 | |
| 73 | void CheckError(const PivotLongerNodeOptions& options, const std::string& message) { |
| 74 | std::shared_ptr<Table> input = gen::Gen({gen::Step(), gen::Random(boolean())}) |
nothing calls this directly
no test coverage detected