Skip to content

Commit 063e799

Browse files
committed
fix erroneous unassigned sortedness check
1 parent 6fa6763 commit 063e799

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Framework/Core/src/Kernels.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ arrow::Status sliceByColumn(
115115
int32_t cur = 0;
116116
int32_t lastNeg = 0;
117117
int32_t lastPos = 0;
118-
118+
bool switchedGroup = false;
119119
auto array = static_cast<arrow::NumericArray<arrow::Int32Type>>(column->chunk(i)->data());
120120
for (auto e = 0; e < array.length(); ++e) {
121121
prev = cur;
@@ -129,17 +129,22 @@ arrow::Status sliceByColumn(
129129
if (lastPos > cur) {
130130
throw runtime_error_f("Table %s index %s is not sorted: next value %d < previous value %d!", target, key, cur, lastPos);
131131
}
132-
if (lastPos == cur && prev < 0) {
132+
if (switchedGroup && lastPos == cur && prev < 0) {
133133
throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev);
134134
}
135135
} else {
136136
if (lastNeg < cur) {
137137
throw runtime_error_f("Table %s index %s is not sorted: next negative value %d > previous negative value %d!", target, key, cur, lastNeg);
138138
}
139-
if (lastNeg == cur && prev >= 0) {
139+
if (switchedGroup && lastNeg == cur && prev >= 0) {
140140
throw runtime_error_f("Table %s index %s has a group with index %d that is split by %d", target, key, cur, prev);
141141
}
142142
}
143+
if (cur != prev) {
144+
switchedGroup = true;
145+
} else {
146+
switchedGroup = false;
147+
}
143148
}
144149
}
145150
std::shared_ptr<arrow::NumericArray<arrow::Int32Type>> values;

0 commit comments

Comments
 (0)