Skip to content

Commit

Permalink
[Bug] fix sort compaction failed on empty input (apache#2766)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitozi authored Jan 23, 2024
1 parent 05c17b1 commit 898c0ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -257,9 +258,10 @@ public void endInput() throws Exception {
T record = sampledData.get((int) (i * avgRange));
boundaries[i - 1] = record;
}
collector.collect(Arrays.asList(boundaries));
} else {
collector.collect(Collections.emptyList());
}

collector.collect(Arrays.asList(boundaries));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,22 @@ public void testRandomSuffixWorks() throws Exception {
Assertions.assertThat(files.size()).isEqualTo(3);
}

@Test
public void testSortCompactionOnEmptyData() throws Exception {
createTable();
SortCompactAction sortCompactAction =
new SortCompactAction(
warehouse,
database,
tableName,
Collections.emptyMap(),
Collections.emptyMap())
.withOrderStrategy("zorder")
.withOrderColumns(Collections.singletonList("f0"));

sortCompactAction.run();
}

private void zorder(List<String> columns) throws Exception {
if (RANDOM.nextBoolean()) {
createAction("zorder", columns).run();
Expand Down

0 comments on commit 898c0ea

Please sign in to comment.