Special function to compare ordered partitions in a way that we compare all floating point values inside using 'epsilon' constant. Returns true if equal.
| 1256 | // To handle the case when the sorting keys are not unique and the order |
| 1257 | // within the same key is not deterministic, we partition the results with |
| 1258 | // sorting keys and verify the partitions are equal using set-diff. |
| 1259 | using OrderedPartition = std::pair<MaterializedRow, MaterializedRowMultiset>; |
| 1260 | |
| 1261 | // Special function to compare ordered partitions in a way that |
| 1262 | // we compare all floating point values inside using 'epsilon' constant. |
| 1263 | // Returns true if equal. |
| 1264 | static bool compareOrderedPartitions( |
| 1265 | const OrderedPartition& expected, |
| 1266 | const OrderedPartition& actual) { |
| 1267 | if (expected.first.size() != actual.first.size() or |
| 1268 | expected.second.size() != actual.second.size()) { |
| 1269 | return false; |
| 1270 | } |
| 1271 | |
| 1272 | for (size_t i = 0; i < expected.first.size(); ++i) { |
| 1273 | if (not expected.first[i].equalsWithEpsilon(actual.first[i])) { |
| 1274 | return false; |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | if (expected.second.empty()) { |
| 1279 | return true; |
| 1280 | } |
| 1281 | |
| 1282 | if (!equalTypeKinds(*expected.second.begin(), *actual.second.begin())) { |
| 1283 | ADD_FAILURE() << "Types of expected and actual results do not match"; |
| 1284 | return false; |
| 1285 | } |
| 1286 | |
| 1287 | auto [numFloatingPointColumns, columns] = |
| 1288 | findFloatingPointColumns(*expected.second.begin()); |
| 1289 | if (numFloatingPointColumns) { |
| 1290 | MaterializedRowEpsilonComparator comparator{ |
| 1291 | numFloatingPointColumns, columns}; |
| 1292 | if (auto result = comparator.areEqual(expected.second, actual.second)) { |
| 1293 | return result.value(); |
| 1294 | } |
| 1295 | } |
| 1296 | // Compare the results directly without epsilon. This may cause false alarm |
| 1297 | // if there are floating-point columns that are computed during the |
no test coverage detected