MCPcopy Create free account
hub / github.com/bytedance/bolt / assertResultsOrdered

Function assertResultsOrdered

bolt/exec/tests/utils/QueryAssertions.cpp:1315–1378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1313 if (not compareOrderedPartitions(expected[i], actual[i])) {
1314 return false;
1315 }
1316 }
1317
1318 return true;
1319}
1320
1321void assertResultsOrdered(
1322 const std::vector<RowVectorPtr>& results,
1323 const RowTypePtr& resultType,
1324 const std::string& duckDbSql,
1325 DuckDbQueryRunner& duckDbQueryRunner,
1326 const std::vector<uint32_t>& sortingKeys) {
1327 std::vector<OrderedPartition> actualPartitions;
1328 std::vector<OrderedPartition> expectedPartitions;
1329
1330 for (const auto& vector : results) {
1331 auto rows = materialize(vector);
1332 for (const auto& row : rows) {
1333 auto keys = getColumns(row, sortingKeys);
1334 if (actualPartitions.empty() || actualPartitions.back().first != keys) {
1335 actualPartitions.emplace_back(keys, MaterializedRowMultiset());
1336 }
1337 actualPartitions.back().second.insert(row);
1338 }
1339 }
1340
1341 auto expectedRows = duckDbQueryRunner.executeOrdered(duckDbSql, resultType);
1342 for (const auto& row : expectedRows) {
1343 auto keys = getColumns(row, sortingKeys);
1344 if (expectedPartitions.empty() || expectedPartitions.back().first != keys) {
1345 expectedPartitions.emplace_back(keys, MaterializedRowMultiset());
1346 }
1347 expectedPartitions.back().second.insert(row);
1348 }
1349
1350 if (not compareOrderedPartitionsVectors(
1351 expectedPartitions, actualPartitions)) {
1352 auto actualPartIter = actualPartitions.begin();
1353 auto expectedPartIter = expectedPartitions.begin();
1354 while (expectedPartIter != expectedPartitions.end() &&
1355 actualPartIter != actualPartitions.end()) {
1356 if (not compareOrderedPartitions(*expectedPartIter, *actualPartIter)) {
1357 break;
1358 }
1359 ++expectedPartIter;
1360 ++actualPartIter;
1361 }
1362 std::ostringstream oss;
1363 if (expectedPartIter == expectedPartitions.end()) {
1364 oss << "Got extra rows: keys: "
1365 << toString(actualPartIter->first, resultType) << std::endl;
1366 } else if (actualPartIter == actualPartitions.end()) {
1367 oss << "Missing rows: keys: "
1368 << toString(expectedPartIter->first, resultType) << std::endl;
1369 } else {
1370 if (actualPartIter->first != expectedPartIter->first) {
1371 oss << "Expected keys: "
1372 << toString(expectedPartIter->first, resultType)

Callers 2

assertQueryFunction · 0.85
assertResultsMethod · 0.85

Calls 13

materializeFunction · 0.85
getColumnsFunction · 0.85
compareOrderedPartitionsFunction · 0.85
generateUserFriendlyDiffFunction · 0.85
backMethod · 0.80
executeOrderedMethod · 0.80
strMethod · 0.80
toStringFunction · 0.70
emptyMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected