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

Function TEST

cpp/src/arrow/acero/pivot_longer_node_test.cc:39–78  ·  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", "feature3"};
47 options.measurement_field_names = {"meas1", "meas2"};
48 options.row_templates = {
49 {{std::make_shared<StringScalar>("a"), std::make_shared<StringScalar>("x"),
50 std::make_shared<UInt32Scalar>(12)},
51 {{1}, {3}}},
52 {{std::make_shared<StringScalar>("b"), std::make_shared<StringScalar>("y"),
53 std::make_shared<UInt32Scalar>(13)},
54 {{2}, std::nullopt}}};
55
56 Declaration plan = Declaration::Sequence({
57 {"table_source", TableSourceNodeOptions(std::move(input))},
58 {"pivot_longer", options},
59 });
60
61 ASSERT_OK_AND_ASSIGN(std::shared_ptr<Table> output,
62 DeclarationToTable(std::move(plan)));
63
64 std::shared_ptr<Schema> expected_out_schema = schema({
65 field("f0", uint32()),
66 field("f1", uint32()),
67 field("f2", uint32()),
68 field("f3", uint32()),
69 field("feature1", utf8()),
70 field("feature2", utf8()),
71 field("feature3", uint32()),
72 field("meas1", uint32()),
73 field("meas2", uint32()),
74 });
75
76 ASSERT_EQ(output->num_rows(), kNumBatches * kRowsPerBatch * 2);
77 AssertSchemaEqual(expected_out_schema, output->schema());
78}
79
80void CheckError(const PivotLongerNodeOptions& options, const std::string& message,
81 StatusCode code = StatusCode::Invalid) {

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