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

Function TEST

cpp/src/arrow/acero/hash_aggregate_test.cc:91–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89namespace acero {
90
91TEST(AggregateSchema, NoKeys) {
92 auto input_schema = schema({field("x", int32())});
93 EXPECT_RAISES_WITH_MESSAGE_THAT(
94 Invalid, HasSubstr("is a hash aggregate function"),
95 aggregate::MakeOutputSchema(input_schema, {}, {},
96 {{"hash_count", nullptr, "x", "hash_count"}}));
97 ASSERT_OK_AND_ASSIGN(auto output_schema,
98 aggregate::MakeOutputSchema(input_schema, {}, {},
99 {{"count", nullptr, "x", "count"}}));
100 AssertSchemaEqual(schema({field("count", int64())}), output_schema);
101}
102
103TEST(AggregateSchema, SingleKey) {
104 auto input_schema = schema({field("x", int32()), field("y", int32())});
105 EXPECT_RAISES_WITH_MESSAGE_THAT(
106 Invalid, HasSubstr("is a scalar aggregate function"),
107 aggregate::MakeOutputSchema(input_schema, {FieldRef("y")}, {},
108 {{"count", nullptr, "x", "count"}}));
109 ASSERT_OK_AND_ASSIGN(
110 auto output_schema,
111 aggregate::MakeOutputSchema(input_schema, {FieldRef("y")}, {},
112 {{"hash_count", nullptr, "x", "hash_count"}}));
113 AssertSchemaEqual(schema({field("y", int32()), field("hash_count", int64())}),
114 output_schema);
115}
116
117TEST(AggregateSchema, DoubleKey) {
118 auto input_schema =
119 schema({field("x", int32()), field("y", int32()), field("z", int32())});
120 ASSERT_OK_AND_ASSIGN(
121 auto output_schema,
122 aggregate::MakeOutputSchema(input_schema, {FieldRef("z"), FieldRef("y")}, {},
123 {{"hash_count", nullptr, "x", "hash_count"}}));
124 AssertSchemaEqual(
125 schema({field("z", int32()), field("y", int32()), field("hash_count", int64())}),
126 output_schema);
127}
128
129TEST(AggregateSchema, SingleSegmentKey) {
130 auto input_schema = schema({field("x", int32()), field("y", int32())});
131 ASSERT_OK_AND_ASSIGN(auto output_schema,
132 aggregate::MakeOutputSchema(input_schema, {}, {FieldRef("y")},
133 {{"count", nullptr, "x", "count"}}));
134 AssertSchemaEqual(schema({field("y", int32()), field("count", int64())}),
135 output_schema);
136}
137
138TEST(AggregateSchema, DoubleSegmentKey) {
139 auto input_schema =
140 schema({field("x", int32()), field("y", int32()), field("z", int32())});
141 ASSERT_OK_AND_ASSIGN(
142 auto output_schema,
143 aggregate::MakeOutputSchema(input_schema, {}, {FieldRef("z"), FieldRef("y")},
144 {{"count", nullptr, "x", "count"}}));
145 AssertSchemaEqual(
146 schema({field("z", int32()), field("y", int32()), field("count", int64())}),
147 output_schema);
148}

Callers 1

ASSERT_OK_AND_ASSIGNFunction · 0.70

Calls 13

SortIndicesFunction · 0.85
TakeFunction · 0.85
push_backMethod · 0.80
emplace_backMethod · 0.80
MakeOutputSchemaFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.70
schemaFunction · 0.50
fieldFunction · 0.50
MakeFunction · 0.50
fieldsMethod · 0.45
idMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected