Skip to content

Commit e685562

Browse files
committed
DPL Analysis: fix incompatible Join check
1 parent 7c19dff commit e685562

3 files changed

Lines changed: 29 additions & 11 deletions

File tree

‎Framework/Core/include/Framework/ArrowTypes.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct ArrowRange {
2424

2525
bool operator!=(ArrowRange const& other) const
2626
{
27-
return (offset != other.offset) && (size != other.size);
27+
return (offset != other.offset) || (size != other.size);
2828
}
2929
};
3030

‎Framework/Core/src/ASoA.cxx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void canNotJoin(std::vector<std::shared_ptr<arrow::Table>> const& tables, std::s
8989
{
9090
for (auto i = 0U; i < tables.size() - 1; ++i) {
9191
if (tables[i]->num_rows() != tables[i + 1]->num_rows()) {
92-
throw o2::framework::runtime_error_f("Tables %s and %s have different sizes (%d vs %d) and cannot be joined!",
93-
makeString(labels[i]), makeString(labels[i + 1]), tables[i]->num_rows(), tables[i + 1]->num_rows());
92+
throw o2::framework::runtime_error_f("Tables %s and %s have different sizes (%lld vs %lld) and cannot be joined!",
93+
makeString(labels[i]), makeString(labels[i + 1]), (long long)tables[i]->num_rows(), (long long)tables[i + 1]->num_rows());
9494
}
9595
}
9696
}
@@ -102,11 +102,20 @@ void IncompatibleRanges(std::vector<ArrowTableRef> const& tables, std::span<T> l
102102
if (loc != std::ranges::cend(tables)) {
103103
auto pos = std::distance(tables.begin(), loc);
104104
auto next = loc + 1;
105+
if (loc->range.size != next->range.size) {
106+
if (labels.empty()) {
107+
throw o2::framework::runtime_error_f("Tables at positions %d and %d have different sizes (%lld vs %lld) and cannot be joined!",
108+
(int)pos, (int)pos + 1, (long long)loc->range.size, (long long)next->range.size);
109+
}
110+
throw o2::framework::runtime_error_f("Tables %s and %s have different sizes (%lld vs %lld) and cannot be joined!",
111+
makeString(labels[pos]), makeString(labels[pos + 1]), (long long)loc->range.size, (long long)next->range.size);
112+
}
105113
if (labels.empty()) {
106-
throw o2::framework::runtime_error_f("Incompatible ranges at %d: (%zu, %z) vs. (%zu, %z)", pos, loc->range.offset, loc->range.size, next->range.offset, next->range.size);
107-
} else {
108-
throw o2::framework::runtime_error_f("Incompatible ranges at %d between %s and %s: (%zu, %z) vs. (%zu, %z)", pos, makeString(labels[pos]), makeString(labels[pos + 1]), loc->range.offset, loc->range.size, next->range.offset, next->range.size);
114+
throw o2::framework::runtime_error_f("Incompatible ranges at %d: (%llu, %lld) vs. (%llu, %lld)",
115+
(int)pos, (unsigned long long)loc->range.offset, (long long)loc->range.size, (unsigned long long)next->range.offset, (long long)next->range.size);
109116
}
117+
throw o2::framework::runtime_error_f("Incompatible ranges at %d between %s and %s: (%llu, %lld) vs. (%llu, %lld)",
118+
(int)pos, makeString(labels[pos]), makeString(labels[pos + 1]), (unsigned long long)loc->range.offset, (long long)loc->range.size, (unsigned long long)next->range.offset, (long long)next->range.size);
110119
}
111120
}
112121

‎Framework/Core/test/test_ASoA.cxx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,20 @@ TEST_CASE("TestJoinedTables")
316316
REQUIRE(15 == test.x() + test.y() + test.z());
317317
}
318318

319-
try {
320-
auto testF = join(TestZ{tableZ}, TestW{tableW});
321-
} catch (RuntimeErrorRef ref) {
322-
REQUIRE(std::string{error_from_ref(ref).what} == "Tables TEST and TEST have different sizes (8 vs 3) and cannot be joined!");
323-
}
319+
// a table of different size must be detected in any position of the join
320+
auto joinError = [](auto&& makeJoin) -> std::string {
321+
try {
322+
makeJoin();
323+
} catch (RuntimeErrorRef ref) {
324+
return error_from_ref(ref).what;
325+
}
326+
return "";
327+
};
328+
REQUIRE(joinError([&] { join(TestZ{tableZ}, TestW{tableW}); }) == "Tables TEST and TEST have different sizes (8 vs 3) and cannot be joined!");
329+
REQUIRE(joinError([&] { join(TestW{tableW}, TestY{tableY}, TestZ{tableZ}); }) == "Tables TEST and TEST have different sizes (3 vs 8) and cannot be joined!");
330+
REQUIRE(joinError([&] { join(TestX{tableX}, TestW{tableW}, TestZ{tableZ}); }) == "Tables TEST and TEST have different sizes (8 vs 3) and cannot be joined!");
331+
REQUIRE(joinError([&] { join(TestX{tableX}, TestY{tableY}, TestW{tableW}); }) == "Tables TEST and TEST have different sizes (8 vs 3) and cannot be joined!");
332+
REQUIRE(joinError([&] { Join<TestX, TestY, TestW>{{tableX, tableY, tableW}}; }) == "Tables at positions 1 and 2 have different sizes (8 vs 3) and cannot be joined!");
324333
}
325334

326335
TEST_CASE("TestConcatTables")

0 commit comments

Comments
 (0)