MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/acero/pivot_longer_node_test.cc:39–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37constexpr int kRowsPerBatch = 64;
38
39TEST(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
73void CheckError(const PivotLongerNodeOptions& options, const std::string& message) {
74 std::shared_ptr<Table> input = gen::Gen({gen::Step(), gen::Random(boolean())})

Callers

nothing calls this directly

Calls 15

StepFunction · 0.85
TableSourceNodeOptionsFunction · 0.85
DeclarationToTableFunction · 0.85
CheckErrorFunction · 0.85
TableFromJSONFunction · 0.85
field_refFunction · 0.85
AssertTablesEqualFunction · 0.85
FailOnErrorMethod · 0.80
ASSERT_OK_AND_ASSIGNFunction · 0.70
GenFunction · 0.50
schemaFunction · 0.50
fieldFunction · 0.50

Tested by

no test coverage detected