Skip to content

Commit 8818ea6

Browse files
authored
DPL Analysis: add exception for unsorted unassigned groups (#7998)
* DPL Analysis: add exception for unsorted unassigned groups If unassigned groups are in incorrect order (or split), fast grouping is invalid due to incorrect offsets, so the execution should stop. * improve the logic to handle groups split by opposite-signed index * fixup! improve the logic to handle groups split by opposite-signed index
1 parent 67c193c commit 8818ea6

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

Framework/Core/include/Framework/Kernels.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,30 @@ auto sliceByColumn(
8181
for (auto i = 0; i < column->num_chunks(); ++i) {
8282
T prev = 0;
8383
T cur = 0;
84+
T lastNeg = 0;
85+
T lastPos = 0;
86+
8487
auto array = static_cast<arrow::NumericArray<typename detail::ConversionTraits<T>::ArrowType>>(column->chunk(i)->data());
8588
for (auto e = 0; e < array.length(); ++e) {
86-
if (cur >= 0) {
87-
prev = cur;
89+
prev = cur;
90+
if (prev >= 0) {
91+
lastPos = prev;
92+
} else {
93+
lastNeg = prev;
8894
}
8995
cur = array.Value(e);
90-
if (cur >= 0 && prev > cur) {
91-
throw runtime_error_f("Table %s index %s is not sorted: next value %d < previous value %d!", target, key, cur, prev);
96+
if (cur >= 0) {
97+
if (lastPos > cur) {
98+
throw runtime_error_f("Table %s index %s is not sorted: next value %d < previous value %d!", target, key, cur, lastPos);
99+
} else if (lastPos == cur && prev < 0) {
100+
throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev);
101+
}
102+
} else {
103+
if (lastNeg < cur) {
104+
throw runtime_error_f("Table %s index %s is not sorted: next negative value %d > previous negative value %d!", target, key, cur, lastNeg);
105+
} else if (lastNeg == cur && prev >= 0) {
106+
throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev);
107+
}
92108
}
93109
}
94110
}

0 commit comments

Comments
 (0)