You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "zhuangchong (via GitHub)" <gi...@apache.org> on 2023/03/24 00:48:28 UTC

[GitHub] [incubator-paimon] zhuangchong commented on a diff in pull request #702: [core] Return sorted snapshot rows by default

zhuangchong commented on code in PR #702:
URL: https://github.com/apache/incubator-paimon/pull/702#discussion_r1147012584


##########
paimon-core/src/main/java/org/apache/paimon/table/system/SnapshotsTable.java:
##########
@@ -194,11 +195,18 @@ public RecordReader<InternalRow> createReader(Split split) throws IOException {
             Path location = ((SnapshotsSplit) split).location;
             Iterator<Snapshot> snapshots = new SnapshotManager(fileIO, location).snapshots();
             Iterator<InternalRow> rows = Iterators.transform(snapshots, this::toRow);
-            if (projection != null) {
+
+            if (projection != null && projection.length != 0) {
                 rows =
                         Iterators.transform(
                                 rows, row -> ProjectedRow.from(projection).replaceRow(row));
             }
+
+            rows =
+                    Arrays.stream(Iterators.toArray(rows, InternalRow.class))
+                            .sorted(Comparator.comparingLong(row -> row.getLong(0)))
+                            .iterator();
+

Review Comment:
   Is it better to proactively add an order statement to the query sql?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org