diff --git a/Framework/Core/include/Framework/Kernels.h b/Framework/Core/include/Framework/Kernels.h index 3a5d06bfb0dc3..1355968559868 100644 --- a/Framework/Core/include/Framework/Kernels.h +++ b/Framework/Core/include/Framework/Kernels.h @@ -81,14 +81,30 @@ auto sliceByColumn( for (auto i = 0; i < column->num_chunks(); ++i) { T prev = 0; T cur = 0; + T lastNeg = 0; + T lastPos = 0; + auto array = static_cast::ArrowType>>(column->chunk(i)->data()); for (auto e = 0; e < array.length(); ++e) { - if (cur >= 0) { - prev = cur; + prev = cur; + if (prev >= 0) { + lastPos = prev; + } else { + lastNeg = prev; } cur = array.Value(e); - if (cur >= 0 && prev > cur) { - throw runtime_error_f("Table %s index %s is not sorted: next value %d < previous value %d!", target, key, cur, prev); + if (cur >= 0) { + if (lastPos > cur) { + throw runtime_error_f("Table %s index %s is not sorted: next value %d < previous value %d!", target, key, cur, lastPos); + } else if (lastPos == cur && prev < 0) { + throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev); + } + } else { + if (lastNeg < cur) { + throw runtime_error_f("Table %s index %s is not sorted: next negative value %d > previous negative value %d!", target, key, cur, lastNeg); + } else if (lastNeg == cur && prev >= 0) { + throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev); + } } } }